Skip to content

useMongocampWebhooks ​

Outbound webhooks of server 3.0 (administrators). Used by MongocampWebhooks.

ts
const { list, create, update, remove, deliveries } = useMongocampWebhooks()
const { row, secret } = await create({ url: 'https://hooks.example.org/orders', events: ['document:create'], collections: ['orders'] })
await update(row.id, { active: false })
const latest = await deliveries(row.id) // newest first
  • list() — GET /system/webhooks as rows (utils/webhooks.ts webhookRow: collections: [] = every collection, declared, disabledAt in ms).
  • create(request) — answers { row, secret }: the only time the server sends the secret.
  • update(id, changes) — PATCH with the fields to change (url, events, collections, active, includeDocuments); collections: [] = every collection; no events is a 400.
  • remove(id) — DELETE; 404 counts as removed.
  • deliveries(id, { rowsPerPage = 50 }) — GET …/deliveries (7 days), newest first: { id, event, collection, attempt, ok, status, error, durationMs, at, jobId }.

All calls have a 15 s timeout. Form helpers in utils/webhooks.ts: webhookFormProblems (http(s), no credentials, an event), webhookRequest(form, original?) (create body / only the changes), normalizeEvents (* wins).

Released under the MIT License.