Building
Webhooks
# Webhooks
## Setting the address
The webhook address is set on your account's Webhook page. There is one for all your workspaces, https only.
## What arrives
Each event comes as a POST request with JSON of four fields: `type`, `timestamp`, `workspace` and `data`. `workspace` is its workspace: `id`, the Workspace ID from the workspace's Settings page, which never changes, and `name`, its current name. Tell the events of your workspaces apart by `workspace.id` when you have several.
| Event | When it comes |
| --- | --- |
| [`message.received`](https://airbox.kz/en/docs/api/message-received) | A customer wrote to you. |
| [`message.status`](https://airbox.kz/en/docs/api/message-status) | A message changed status. |
| [`message.refused`](https://airbox.kz/en/docs/api/message-refused) | A message will not go. |
| [`channel.updated`](https://airbox.kz/en/docs/api/channel-updated) | A channel was connected or cut off, or an alert came or went. |
| `webhook.test` | You sent a test from the workspace's Webhook deliveries page. Answer 2xx and ignore it. |
## Verifying the signature
Every event is signed the Standard Webhooks way, in three headers:
- `webhook-id`: the event's id, the same on every retry.
- `webhook-timestamp`: when it was sent, in Unix seconds.
- `webhook-signature`: one or more signatures, each `v1,` followed by a base64 HMAC, separated by spaces.
The signing secret starts with `whsec_`. Keep it in an environment variable, for example `WEBHOOK_SECRET`.
### With a library
Use the Standard Webhooks library for your language. It checks all of it in one call:
- Node.js: `standardwebhooks`
- PHP: `standard-webhooks/standard-webhooks`
- Python: `standardwebhooks`
- Go: `github.com/standard-webhooks/standard-webhooks/libraries/go`
- .NET: `StandardWebhooks.StandardWebhooks`
- Rust: `standardwebhooks`
```javascript Node.js
// npm install express standardwebhooks
import express from "express";
import { Webhook } from "standardwebhooks";
const webhook = new Webhook(process.env.WEBHOOK_SECRET);
const app = express();
app.post("/webhooks", express.raw({ type: "application/json" }), (req, res) => {
let event;
try {
event = webhook.verify(req.body, req.headers);
} catch {
return res.sendStatus(400);
}
res.sendStatus(200);
console.log(event.type, event.workspace.id, event.data);
});
app.listen(3000);
```
```php PHP
<?php
// composer require standard-webhooks/standard-webhooks
require __DIR__.'/vendor/autoload.php';
$webhook = new \StandardWebhooks\Webhook(getenv('WEBHOOK_SECRET'));
$body = file_get_contents('php://input');
try {
$webhook->verify($body, [
'webhook-id' => $_SERVER['HTTP_WEBHOOK_ID'] ?? '',
'webhook-timestamp' => $_SERVER['HTTP_WEBHOOK_TIMESTAMP'] ?? '',
'webhook-signature' => $_SERVER['HTTP_WEBHOOK_SIGNATURE'] ?? '',
]);
} catch (Exception) {
http_response_code(400);
exit;
}
http_response_code(200);
$event = json_decode($body, true);
```
```python Python
# pip install flask standardwebhooks
import os
from flask import Flask, request
from standardwebhooks.webhooks import Webhook
app = Flask(__name__)
webhook = Webhook(os.environ["WEBHOOK_SECRET"])
@app.post("/webhooks")
def receive():
try:
webhook.verify(request.get_data(), dict(request.headers))
except Exception:
return "", 400
event = request.get_json()
return "", 200
```
```go Go
// go get github.com/standard-webhooks/standard-webhooks/libraries/go
package main
import (
"io"
"net/http"
"os"
standardwebhooks "github.com/standard-webhooks/standard-webhooks/libraries/go"
)
func main() {
webhook, err := standardwebhooks.NewWebhook(os.Getenv("WEBHOOK_SECRET"))
if err != nil {
panic(err)
}
http.HandleFunc("POST /webhooks", func(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(r.Body)
if err != nil || webhook.Verify(body, r.Header) != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
w.WriteHeader(http.StatusOK)
})
http.ListenAndServe(":3000", nil)
}
```
```csharp .NET
// dotnet add package StandardWebhooks.StandardWebhooks
using StandardWebhooks;
var app = WebApplication.CreateBuilder(args).Build();
var webhook = new Webhook(Environment.GetEnvironmentVariable("WEBHOOK_SECRET")!);
app.MapPost("/webhooks", async (HttpRequest request) =>
{
var body = await new StreamReader(request.Body).ReadToEndAsync();
try
{
webhook.Verify(body, name => request.Headers[name!].ToString());
}
catch (Exception)
{
return Results.BadRequest();
}
return Results.Ok();
});
app.Run();
```
```rust Rust
// cargo add standardwebhooks axum tokio --features tokio/full
use axum::{body::Bytes, http::{HeaderMap, StatusCode}, routing::post, Router};
use standardwebhooks::Webhook;
async fn receive(headers: HeaderMap, body: Bytes) -> StatusCode {
let secret = std::env::var("WEBHOOK_SECRET").unwrap();
let webhook = Webhook::new(&secret).unwrap();
match webhook.verify(&body, &headers) {
Ok(()) => StatusCode::OK,
Err(_) => StatusCode::BAD_REQUEST,
}
}
#[tokio::main]
async fn main() {
let app = Router::new().route("/webhooks", post(receive));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}
```
### By hand
1. Take the body exactly as it arrived, before parsing the JSON.
2. Base64-decode the part of the secret after `whsec_`.
3. With that key, compute the HMAC-SHA256 of `webhook-id.webhook-timestamp.body` and base64-encode it.
4. Compare it with each signature after `v1,` in `webhook-signature`, in constant time.
5. Reject the event if `webhook-timestamp` is more than 5 minutes off your clock.
## Answering and retries
If the address does not answer 2xx, we try again: 8 tries in all over about 21 h. If the address fails for longer than 24 h while events keep coming, sending pauses, and new events wait until it is resumed on the workspace's Webhook deliveries page or a new address is saved. That page shows every try, and sends the test event `webhook.test`: answer it 2xx, its `data` holds only `message`.
| Try | Wait before it |
| --- | --- |
| 1 | At once |
| 2 | 10 seconds |
| 3 | 1 minute |
| 4 | 5 minutes |
| 5 | 30 minutes |
| 6 | 2 hours |
| 7 | 6 hours |
| 8 | 12 hours |
## In your account
- The account's **Webhook** page sets the address, the events it hears and the signing secret. A new secret signs every event at once, so update your server first.
- Each workspace's **Webhook deliveries** page lists its events with every try and the payload. They are kept 30 days.
- **Resend** sends one event again and **Resend undelivered** every event that ran out of tries, on a fresh schedule and with the same `webhook-id`. Neither works while deliveries are paused: **Resume** sends what waited.
- **Send test event** sends `webhook.test` once, even while deliveries are paused or the address skips other events.
Updated 4 December 2026
Setting the address
The webhook address is set on your account's Webhook page. There is one for all your workspaces, https only.
What arrives
Each event comes as a POST request with JSON of four fields: type, timestamp, workspace and data. workspace is its workspace: id, the Workspace ID from the workspace's Settings page, which never changes, and name, its current name. Tell the events of your workspaces apart by workspace.id when you have several.
| Event | When it comes |
|---|---|
message.received |
A customer wrote to you. |
message.status |
A message changed status. |
message.refused |
A message will not go. |
channel.updated |
A channel was connected or cut off, or an alert came or went. |
webhook.test |
You sent a test from the workspace's Webhook deliveries page. Answer 2xx and ignore it. |
Verifying the signature
Every event is signed the Standard Webhooks way, in three headers:
webhook-id: the event's id, the same on every retry.webhook-timestamp: when it was sent, in Unix seconds.webhook-signature: one or more signatures, eachv1,followed by a base64 HMAC, separated by spaces.
The signing secret starts with whsec_. Keep it in an environment variable, for example WEBHOOK_SECRET.
With a library
Use the Standard Webhooks library for your language. It checks all of it in one call:
- Node.js:
standardwebhooks - PHP:
standard-webhooks/standard-webhooks - Python:
standardwebhooks - Go:
github.com/standard-webhooks/standard-webhooks/libraries/go - .NET:
StandardWebhooks.StandardWebhooks - Rust:
standardwebhooks
// npm install express standardwebhooks
import express from "express";
import { Webhook } from "standardwebhooks";
const webhook = new Webhook(process.env.WEBHOOK_SECRET);
const app = express();
app.post("/webhooks", express.raw({ type: "application/json" }), (req, res) => {
let event;
try {
event = webhook.verify(req.body, req.headers);
} catch {
return res.sendStatus(400);
}
res.sendStatus(200);
console.log(event.type, event.workspace.id, event.data);
});
app.listen(3000);
By hand
- Take the body exactly as it arrived, before parsing the JSON.
- Base64-decode the part of the secret after
whsec_. - With that key, compute the HMAC-SHA256 of
webhook-id.webhook-timestamp.bodyand base64-encode it. - Compare it with each signature after
v1,inwebhook-signature, in constant time. - Reject the event if
webhook-timestampis more than 5 minutes off your clock.
Answering and retries
If the address does not answer 2xx, we try again: 8 tries in all over about 21 h. If the address fails for longer than 24 h while events keep coming, sending pauses, and new events wait until it is resumed on the workspace's Webhook deliveries page or a new address is saved. That page shows every try, and sends the test event webhook.test: answer it 2xx, its data holds only message.
| Try | Wait before it |
|---|---|
| 1 | At once |
| 2 | 10 seconds |
| 3 | 1 minute |
| 4 | 5 minutes |
| 5 | 30 minutes |
| 6 | 2 hours |
| 7 | 6 hours |
| 8 | 12 hours |
Answer 2xx within 5 seconds and do long work in the background. After any other response or a timeout the event comes again with the same webhook-id, so use it to drop repeats. Any other response, 3xx and 4xx included, counts as a failure.
In your account
- The account's Webhook page sets the address, the events it hears and the signing secret. A new secret signs every event at once, so update your server first.
- Each workspace's Webhook deliveries page lists its events with every try and the payload. They are kept 30 days.
- Resend sends one event again and Resend undelivered every event that ran out of tries, on a fresh schedule and with the same
webhook-id. Neither works while deliveries are paused: Resume sends what waited. - Send test event sends
webhook.testonce, even while deliveries are paused or the address skips other events.