Webhooks
A webhook tells your server that something changed on your masjid, so you do not have to poll. Masjidbox posts a small event to a URL you register; your server then reads the changed resource with its key.
Register an endpoint
Endpoints belong to your organization, not to a key: revoking the key that registered one does not silence it. Register one in your dashboard under API → Webhooks, or with a secret key holding Masjid profile: read:
curl -X POST https://hub.masjidbox.com/v1/masjid/webhook-endpoints \
-H "Authorization: Bearer mbx_sk_live_…" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.org/masjidbox/webhooks", "events": ["event.created", "event.updated"]}'- The URL must be
https, on a public host name, with no user or password in it. - Five endpoints per organization.
- The answer carries the endpoint's signing secret,
whsec_…, once. Store it now: it is never shown again. If you lose it, rotate it (below). - Subscribing to an event needs the read right of its product on the key, in the tables below (else
403).
Events
Every event of a product needs that product's read right on the key. data.id is the prefix of the resource's id, or null when the event is about the whole masjid or a singleton (read the resource itself then).
Masjid profile
| Event | When | data.id |
|---|---|---|
masjid.updated | The organization changed | null |
profile.updated | The public profile changed (contact, capacity, facilities) | null |
Prayer times
| Event | When | data.id |
|---|---|---|
prayer_times.updated | The prayer times changed (calculation method, athan or iqamah rules, timetable, special times) | null |
jumuah_times.updated | The jumu'ah services changed | null |
Content
| Event | When | data.id |
|---|---|---|
event.created, event.updated, event.deleted | An event | evt_… |
announcement.created, announcement.updated, announcement.deleted | An announcement | ann_… |
media.created, media.updated, media.deleted | A media (an upload confirmed is a media.created) | med_… |
news.created, news.updated, news.deleted | A news item | nws_… |
album.created, album.updated, album.deleted | An album | alb_… |
collection.created, collection.updated, collection.deleted | A collection | col_… |
poll.created, poll.updated, poll.deleted | A poll (a vote is not a change of the poll) | pol_… |
quiz.created, quiz.updated, quiz.deleted | A quiz (a play is not a change of the quiz) | qiz_… |
question.updated, question.deleted | An ask-the-imam question answered, archived or deleted | qst_… |
live.created, live.updated, live.deleted | A live | liv_… |
A question is asked in the app, so there is no question.created. A question event carries its id only: Content: read subscribes to it, and reading the question itself takes a secret key. Activating a live deactivates your other lives without an event for each: read GET /v1/masjid/lives after a live.updated.
Notifications
| Event | When | data.id |
|---|---|---|
notification.created, notification.updated, notification.deleted | A Masjidbox One notification | ntf_… |
app_notification.created, app_notification.updated, app_notification.deleted | A scheduled app push | apn_… |
app_recurring_notification.created, app_recurring_notification.updated, app_recurring_notification.deleted | A recurring app push | arn_… |
app_one_time_notification.created, app_one_time_notification.updated, app_one_time_notification.deleted | A one-time app push | aon_… |
Donation campaigns
| Event | When | data.id |
|---|---|---|
donation_account.updated | The donation account | null |
donation_campaign.created, donation_campaign.updated, donation_campaign.deleted | A donation campaign | cmp_… |
No event carries donor data: donations, recurring donations and receipts send none. Read them with their cursor (updatedSince) instead.
Website and app
| Event | When | data.id |
|---|---|---|
website.updated | The website (closed, maintenance) | null |
widget.created, widget.updated, widget.deleted | A website widget | wdg_… |
app_widget.updated | The app's widget | null |
app_popup.created, app_popup.updated, app_popup.deleted | An app popup | apo_… |
app_page.created, app_page.updated, app_page.deleted | An app page (its popup included) | the page's id |
Screens
| Event | When | data.id |
|---|---|---|
screen.updated, screen.deleted | A screen (a player, an android, a tizen) | scr_… |
screen_settings.updated | The screen settings | null |
playlist.created, playlist.updated, playlist.deleted | A playlist (a duplicate is a playlist.created) | pll_… |
playlist_schedule.created, playlist_schedule.updated, playlist_schedule.deleted | A playlist schedule | psc_… |
A screen is paired on the screen itself, so there is no screen.created. Statistics send no event.
Events are sent whether the change was made in the dashboard or through the API.
The payload
An event names what changed, never its content. Read the resource with your key to get its current state:
{
"id": "whe_9f8e7d6c5b4a39281706f5e4d3c2b1a0",
"type": "event.updated",
"createdAt": "2026-11-17T09:00:00.000Z",
"data": { "object": "event", "id": "evt_…" }
}data.idis the resource's id, under the prefix of the tables above. It isnullfor the events about the whole masjid or a singleton (prayer_times.updated,masjid.updated,website.updated…): read that resource then.- After a
*.deletedevent, the resource answers404. prayer_times.updatedwaits 30 seconds before it is sent, so a burst of changes is one event.
Verify the signature
Every request carries a Masjidbox-Signature header:
Masjidbox-Signature: t=1731830400,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bdt is when Masjidbox signed the request, in Unix seconds. Each v1 is the hex HMAC-SHA256 of <t>.<raw body>, keyed with the endpoint's secret. There are two v1 for 24 hours after a rotation, one per secret: accept the request if one matches.
Verify the raw body, byte for byte, before you parse it. Refuse a request whose t is more than five minutes old, so a captured request cannot be replayed. In Node.js:
import { createHmac, timingSafeEqual } from 'node:crypto';
const TOLERANCE_SECONDS = 300;
export const verifyMasjidboxSignature = (rawBody, header, secret) => {
const parts = header.split(',').map((part) => part.split('='));
const t = Number(parts.find(([key]) => key === 't')?.[1]);
if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > TOLERANCE_SECONDS) return false;
const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`, 'utf8').digest();
return parts
.filter(([key]) => key === 'v1')
.some(([, signature]) => {
const given = Buffer.from(signature, 'hex');
return given.length === expected.length && timingSafeEqual(given, expected);
});
};With Express, read the body as text for that route: express.raw({ type: 'application/json' }), then verifyMasjidboxSignature(req.body.toString('utf8'), req.get('Masjidbox-Signature'), secret). The scheme is Stripe's: a Stripe-style verifier works once pointed at this header.
Answer, retries and disabling
- Answer with any
2xxwithin 10 seconds. Do the work after answering: a slow answer is a failure. - A redirect (
3xx) is a failure: Masjidbox does not follow it. - A failed delivery is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, 12 hours and 24 hours, then marked failed.
- An event can arrive more than once, and events can arrive out of order. Use
idto drop one you have already handled, and read the resource for its current state rather than trusting the order. - An endpoint that fails every delivery for 3 days is disabled, and your organization's owner gets an email. Fix the URL, then turn it back on in the dashboard or with
PATCH /v1/masjid/webhook-endpoints/{id}and{"enabled": true}. The events of the meantime are not resent.
Deliveries and secrets
GET /v1/masjid/webhook-endpoints/{id}/deliverieslists the last 30 days of deliveries: status, attempts, the answer's status code.POST /v1/masjid/webhook-endpoints/{id}/deliveries/{deliveryId}/resendsends one again.POST /v1/masjid/webhook-endpoints/{id}/rotate-secretanswers a new secret, once. The previous one keeps signing for 24 hours, so you can switch without missing an event.
Every operation is in the API reference.