Skip to Content
Integrations

Webhooks

Have the site report payments, new players and other events to a Discord channel or your own service, verify the signature, and know what happens on failures.

A webhook sends a message to your address as soon as something happens on the site: a payment goes through, a player registers, a game account gets linked. The address can be a Discord channel, where the site posts a ready message, or your own service, which receives the event details as JSON and, say, hands out a reward.

Only the site owner can open this screen (the admin.boss permission). Events keep going out as long as whoever added the webhook still has that permission.

Add a webhook

Open the list

AdminWebhooks and click "Add webhook".

The webhooks list with the Address, Events, Failures and Last status columns

Choose where to report

Under "Where to report" 1, pick "Discord channel" or "My own service". For Discord, copy the address from the channel settings: Integrations → Webhooks. For your own service, enter its address 2, starting with https://.

The Add webhook window with Where to report, the address and the event list

Pick the events

In "Events" 3, choose what to report and click "Add webhook" 4. "Every event, including future ones" also subscribes the address to events of modules you install later. Each event name has its code in brackets, for example payment.completed: your service uses it to tell what happened.

For your own service, saving shows "Webhook added. Copy the secret key now, it is shown only once." The key starts with whsec_ and your service checks the signature with it. Discord messages aren't signed and get no key.

A Discord webhook address looks like https://discord.com/api/webhooks/…

"Discord channel" is selected, but the address doesn't lead to a Discord webhook. Copy the whole address from the channel settings: Integrations → Webhooks.

Events

CodeWhen it arrives
user.registereda new player registered
user.updateda player changed their profile
payment.completeda payment went through
payment.refundeda payment was refunded, in full or in part
payment.dispute_openedthe payer disputed a payment with their bank
payment.dispute_resolveda payment dispute was resolved
purchase.completedsomething was bought for the site balance
purchase.refundedthe money of a balance purchase was returned
player.linked, player.unlinkeda game account was linked to a site account or unlinked
moderation.item_arriveda new record arrived in a moderation queue
comment.publisheda comment became visible to everyone

Modules add their own events, and those appear in the same list once the module is installed.

Verify the signature

The site sends a POST with a JSON body to your service:

{"id":"9f86d081884c7d659a2feaa0c55ad015","event":"payment.completed","created":1764150000,"data":{"user":{"id":42,"name":"Kirill"},"payment":{"id":1187,"amount":500}}}

The data fields depend on the event. The headers carry X-Flute-Event (the event code), X-Flute-Delivery (same as id, handy for dropping repeats) and X-Flute-Signature in the form sha256=<hex>. The signature is an HMAC-SHA256 of the raw request body, keyed with the webhook secret:

webhook.php
$body = file_get_contents('php://input');
$expected = 'sha256=' . hash_hmac('sha256', $body, getenv('FLUTE_WEBHOOK_SECRET'));

if (!hash_equals($expected, $_SERVER['HTTP_X_FLUTE_SIGNATURE'] ?? '')) {
    http_response_code(401);
    exit;
}

Compute the signature over the raw body, before parsing the JSON: re-encoding can change the string, and then the signature won't match. Answer with any 2xx code, or the delivery counts as a failure.

Retries and failures

If your service doesn't answer within 5 seconds or returns something other than 2xx, the site tries again: up to 5 attempts in all, with pauses of 2, 4, 8 and 16 seconds. Redirects (3xx) aren't followed and count as failures too. On a 429 answer the site waits as long as Retry-After says (5 minutes at most, up to 5 times) and doesn't count it as a failure.

The "Failures" column shows how many attempts in a row didn't go through, and "Last status" shows the code of the last answer. A successful delivery resets the counter.

A webhook stopped after failures

The address failed 15 times in a row, so the site turned the webhook off. Check that the service is up and answers 2xx, then click "Resume": the failure counter resets.

Webhooks aren't going out

Events are sent by the task queue. When this warning sits above the list, the queue isn't running and events are piling up. Open the scheduler and check that background tasks run.

Pause, edit, delete

"Pause" stops sending events without deleting the webhook, and "Resume" turns it back on. The "Active" switch in the webhook window does the same. Click a row to change the address, the format or the events. "Delete" removes the webhook at once.

Adding, editing and resuming ask you to confirm with your password or a 2FA code.

You can't replace the secret key of an existing webhook. If the key leaks, delete the webhook and add it again: the new one gets a new key.

Troubleshooting

For any other message, use the error lookup.

The address of your own service is checked on saving and again before every delivery. Errors under "Address" come in English:

MessageWhat is wrong
The webhook URL must be an absolute https:// URL.the address lacks https:// or uses http://
The webhook URL must not contain credentials.the address has a login and password in it (https://user:pass@…)
The webhook URL must resolve to a public address.the domain doesn't resolve or points into a private network (localhost, 10.x, 192.168.x)

"Select at least one event." means a webhook without events isn't saved.

Reference

Next

On this page