Skip to Content

Create or replace the domain's event webhook.

One URL per domain, all events, no filters. Mailboxes on the domain start feeding it within seconds (a background walk arms them) — take a baseline first and treat the first batches as deltas. Any PUT re-enables, and re-runs the arm walk: it is the recovery if a walk ever died mid-domain (visible as a dead_lettered arm:<domain> row in the delivery log). What your endpoint receives (payload, X-OpenEmail-Signature scheme, retry policy) is specified as event-batch in this document's top-level webhooks section.

openemail.domains.setEventWebhook(
  domain: string,
  body: DomainsSetEventWebhookBody,
  options?: CallOptions,
): ApiPromise<EventWebhook>

It calls PUT /domains/{domain}/event-webhook: Create or replace the domain's event webhook in the API reference.

Example

const eventWebhook = await openemail.domains.setEventWebhook(domain, {
  secret: 'whsec_5e8a1c9f2b7d4e6a8c1f3b5d7e9a2c4f',
  url: 'https://hooks.acme.example/openemail',
})

Arguments

ArgumentTypeDescription
domainstringDomain name. The path's {domain}.
bodyDomainsSetEventWebhookBodyThe request's body.

Options

It takes no options of its own. Every call also takes signal, timeout, retry and headers, which say how that one call is sent (call options).

Answer

Awaited, it is the API's JSON, EventWebhook. It is an ApiPromise: .withResponse() gives the same with the Response it came in, for its headers.

Errors

StatusWhat it means
400validation_failed — URL refused
401unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a WWW-Authenticate: Bearer challenge
404Domain not found or not accessible to this principal
409account_required: the domain has no owning account, and a hook row must reference one (the legacy directory; once the partitioned directory answers, a platform domain's hook is accepted for the system caller)
413too_large: JSON request body exceeds 1 MiB or 500,000 values (object keys included), checked before parsing
503temporary_failure: the platform's storage could not answer just now; retry after the Retry-After window. Any operation can answer this. A write that got it may have been applied, so retry it with the same idempotency key where it takes one, or read the state back first (see Transient failures in the API description)

A failed call rejects with a RequestError: its status, and its code, the API's error. Decide on the code: one status covers several.

Types

DomainsSetEventWebhookBody

/** The body of `domains.setEventWebhook`. */
type DomainsSetEventWebhookBody = {
  /** HMAC signing secret — write-only. Omit to keep, string to set, null to clear */
  secret?: string | null
  /** HTTPS endpoint on a public host */
  url: string
}

It names these types of the API, each on a page of its own: EventWebhook.