Webhooks
Webhooks
Fox Login sends an HTTP POST to your server when something happens in an application, such as a new sign-up, so you do not have to poll the event log. The body carries IDs only, and each delivery is signed with the endpoint's secret.
Create an endpoint
Creating an endpoint needs applications:write: a secret key with the admin role, or an organization API key. An application can have up to 10 endpoints.
curl https://api.foxlogin.app/v1/applications/app_8f2c91a7/webhooks \
-H "Authorization: Bearer $FOXLOGIN_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{ "url": "https://hooks.example.com/foxlogin", "events": ["user.created", "user.signed_in"] }'const res = await fetch("https://api.foxlogin.app/v1/applications/app_8f2c91a7/webhooks", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FOXLOGIN_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://hooks.example.com/foxlogin",
events: ["user.created", "user.signed_in"],
}),
});
const endpoint = await res.json(); // { id, url, events, secret }{
"id": "whe_8f2c91a7",
"url": "https://hooks.example.com/foxlogin",
"events": ["user.created", "user.signed_in"],
"secret": "whsec_P5wqe+HQTFim8umxfUw6D44rbZHHpPBeO40sah+ee0A="
}The URL must use https and a public hostname: no IP address, port, user name or password, and no localhost, .internal or .local host. A bad URL returns 400 invalid_webhook_url, an unknown event type 400 invalid_events, and an 11th endpoint 422 webhook_limit.
GET /applications/{app_id}/webhooks lists the endpoints without their secrets, plus the event types you can subscribe to. DELETE /applications/{app_id}/webhooks/{endpoint_id} removes one and answers 204.
Events
| Event | Sent when |
|---|---|
user.created |
A user finished sign-up, or you created one through the Management API. |
user.signed_in |
A user signed in. |
sign_in.failed |
A password sign-in failed. |
sign_in.mfa_required |
A sign-in step asked for the second factor. |
password.reset |
A user set a new password with a reset code. |
mfa.enrolled |
A user turned on TOTP. |
mfa.removed |
A user turned off TOTP. |
* |
Every event in the event log. |
sign_up.existing_email and identity.linked appear in the event log, but endpoints cannot subscribe to them by name. An endpoint subscribed to * receives them too.
Payload
POST /foxlogin HTTP/1.1
Host: hooks.example.com
Content-Type: application/json
User-Agent: FoxLogin-Webhooks/1
webhook-id: whd_8f2c91a7_whe_8f2c91a7
webhook-timestamp: 1796202840
webhook-signature: v1,AtLKCNnW832If4jCemtBdc1JjChl3H4Z78UNr2jMm5E=
{
"id": "evt_8f2c91a7",
"type": "user.created",
"created_at": "2026-12-02T09:14:00.000Z",
"data": {
"app_id": "app_8f2c91a7",
"user_id": "usr_tr_8f2c91a7",
"method": "password"
}
}The body never contains an email, name or other personal data. data holds the application ID, the user ID and the same extra fields as the event log, such as method. To show who it was, fetch the user with data.user_id from the Users API.
The headers follow Standard Webhooks. webhook-id stays the same on every retry of a delivery, so use it to skip duplicates.
Verify the signature
webhook-signature is v1, followed by the base64 HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{body}. The HMAC key is the part of the endpoint secret after whsec_, base64-decoded. Compute it over the raw request body before any JSON parsing, compare in constant time, and reject timestamps more than 5 minutes away from your clock.
import crypto from "node:crypto";
import express from "express";
const app = express();
const key = Buffer.from(process.env.FOXLOGIN_WEBHOOK_SECRET!.replace(/^whsec_/, ""), "base64");
app.post("/foxlogin", express.raw({ type: "application/json" }), (req, res) => {
const id = req.get("webhook-id") ?? "";
const timestamp = req.get("webhook-timestamp") ?? "";
const body = req.body.toString("utf8");
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return res.status(400).end();
const expected = crypto.createHmac("sha256", key).update(`${id}.${timestamp}.${body}`).digest();
const valid = (req.get("webhook-signature") ?? "").split(" ").some((part) => {
const [version, sig] = part.split(",");
const given = Buffer.from(sig ?? "", "base64");
return version === "v1" && given.length === expected.length && crypto.timingSafeEqual(given, expected);
});
if (!valid) return res.status(400).end();
const event = JSON.parse(body);
queue.add(event); // do the slow work later
res.status(204).end();
});Any Standard Webhooks library can verify these deliveries as well. The secret, headers and body in the examples above produce the signature shown, so you can test your code with them.
Retries
A delivery succeeds when your endpoint answers with a 2xx status within 10 seconds. Fox Login does not follow redirects. A failed delivery is retried up to 8 attempts in total, waiting 30 seconds after the first failure and twice as long after each next one: 30 s, 1 min, 2 min, 4 min, 8 min, 16 min and 32 min, about an hour in all. Deliveries are kept for 7 days.
- Answer quickly and do slow work in a background job, so the 10-second limit does not turn a slow handler into retries.
- Skip deliveries whose
webhook-idyou have already processed. - Deliveries can arrive out of order after a retry. Use
created_atwhen the order matters.