Add a webhook
Webhooks send a signed POST to your address when something happens: a client is added, a link changes, someone clicks, a domain goes live, an invoice is paid. They’re sent from WordPress and from your edge script, so links made over the API on Bunny are reported too.
In the dashboard: Settings > Developers > Webhooks > Add webhook. Enter the address, pick the events and, if you like, one client. The secret is shown once.

Over the API:
curl -X POST https://api.yourbrand.com/api/partner/webhooks -H 'Authorization: Bearer nl_pk_…' -H 'Content-Type: application/json' \
-d '{"url":"https://app.yourbrand.com/hooks/links","events":["link.*","domain.live"],"description":"My app"}' { "data": { "id": 1, "url": "https://app.yourbrand.com/hooks/links", "secret": "whsec_…", "events": ["link.*", "domain.live"], "client_id": null, "description": "My app", "is_active": true, "fails": 0, "created_by": "Partner API" } } events takes types, groups like link.*, or ["*"]. client left out sends everyone’s events; 0 sends only yours; a client id or ext: id sends one client’s. Addresses must be public http or https addresses.
A receiver in Node.js (Express)#
import express from 'express';
import crypto from 'node:crypto';
const app = express();
const seen = new Set(); // use your database in production
app.post('/hooks/links', express.raw({ type: 'application/json' }), (req, res) => {
const raw = req.body.toString('utf8');
if (!verify(raw, req.get('X-NL-Signature'), process.env.NL_WEBHOOK_SECRET)) return res.sendStatus(401);
res.sendStatus(200); // answer fast
const event = JSON.parse(raw);
if (seen.has(event.id)) return; // retries reuse the id
seen.add(event.id);
handle(event); // do the work after answering
}); verify() is in Check the signature.
A receiver in WordPress#
add_action( 'rest_api_init', function () {
register_rest_route( 'myapp/v1', '/nl-hook', [
'methods' => 'POST',
'permission_callback' => '__return_true',
'callback' => function ( WP_REST_Request $r ) {
$raw = $r->get_body();
if ( ! nahnu_links_verify_webhook( MY_NL_SECRET, $raw, $r->get_header( 'x_nl_signature' ) ?? '' ) ) {
return new WP_REST_Response( null, 401 );
}
$event = json_decode( $raw, true );
// … handle $event['type'] …
return new WP_REST_Response( null, 200 );
},
] );
} ); Good practice#
- Verify every delivery with the signature, and reject old timestamps.
- Answer within 8 seconds. Do slow work afterwards, in a queue.
- Handle each event id once. Retries send the same id.
- Subscribe only to what you need. Click events can be many.
- Use HTTPS for your address.
Test it#
Click Send test on the webhook, or POST /api/partner/webhooks/{id}/test. Your address gets a webhook.test event. See Delivery history.


