Skip to content

API reference

webhooks declares inbound receivers, outbound senders, signature policies, retries, dedupe, replay, and webhook event records.

Terminal window
import { webhooks } from "@layeron/modules"

Declare a Stripe inbound webhook receiver.

TypeSpec operation: webhooksStripe.

Terminal window
webhooks.stripe(options?: WebhookProviderOptions): WebhooksModule

Reference to a Layeron secret used for signing.

FieldTypeDescription
namestringSecret name.
namespacestring | undefinedPlatform namespace for the instance. Defaults to default.

Signature verification or signing settings.

FieldTypeDescription
headerstring | undefinedHeader containing the signature.
headersstring[] | undefinedHeaders that may contain signatures.
queryParamstring | undefinedQuery parameter containing the signature.
extractunknown | undefinedSignature extractor. TypeScript accepts a RegExp or a function (ctx) => string &#124; Promise<string>. The generated contract represents RegExp and function values as unknown because they remain application code values.
algorithmWebhookSignatureAlgorithm | undefinedSignature algorithm.
encodingWebhookSignatureEncoding | undefinedSignature encoding.
secretWebhookSecretRef | undefinedSecret used to verify or sign the payload.
timestampHeaderstring | undefinedHeader containing the timestamp.
timestampQueryParamstring | undefinedQuery parameter containing the timestamp.
toleranceSecondsint32 | undefinedAllowed timestamp skew in seconds.
signedPayloadWebhookSignedPayloadPreset | undefinedPreset used to build the signed payload.
verifyunknown | undefinedCustom verifier. TypeScript accepts a function (ctx) => boolean &#124; Promise<boolean> that receives the request, raw body, headers, method, path, timestamp, extracted signature, and secret value. The generated contract represents the function value as unknown.

Retry policy for webhook delivery.

FieldTypeDescription
attemptsint32 | undefinedMaximum delivery attempts.
backoff”fixed” | “exponential” | undefinedRetry backoff mode.
initialDelaySecondsint32 | undefinedFirst retry delay in seconds.
maxDelaySecondsint32 | undefinedMaximum retry delay in seconds.

Duplicate detection settings.

FieldTypeDescription
keystring | undefinedPayload field or expression used as the idempotency key.
ttlstring | undefinedDuplicate retention duration.

Delivery settings for inbound webhook handlers.

FieldTypeDescription
queueboolean | undefinedWhether delivery should be queued.
retryWebhookRetryOptions | undefinedRetry policy.
deadLetterboolean | undefinedWhether exhausted events should move to dead letter state.

Options shared by inbound provider helpers.

FieldTypeDescription
namestring | undefinedStable webhook instance name.
namespacestring | undefinedPlatform namespace for the instance. Defaults to default.
pathstring | undefinedGateway path used for inbound delivery.
hoststring | undefinedDedicated host used for inbound delivery.
urlstring | undefinedAbsolute URL used to infer host or path placement.
secretWebhookSecretRef | undefinedSecret used for provider signatures.
dedupeWebhookDedupeOptions | undefinedDuplicate detection settings.
deliveryWebhookDeliveryOptions | undefinedDelivery settings.
onRecord<unknown> | undefinedEvent-specific handler map. TypeScript accepts Record<string, WebhookEventHandler> keyed by provider event type. The generated contract represents handler functions as unknown values because they remain application code values.
handlerunknown | undefinedSingle inbound handler. TypeScript accepts a WebhookEventHandler function. The generated contract represents the function value as unknown because it remains application code.
observabilityLayeron.Observability.ObservabilityConfig | undefinedObservability settings for webhook events, attempts, and replay.

Options accepted by webhooks.custom().

FieldTypeDescription
namestringStable webhook instance name.
signatureWebhookSignatureConfig | undefinedCustom signature verification settings.

Outbound endpoint settings.

FieldTypeDescription
namestringStable endpoint name.
urlstringDestination URL.
signingWebhookSignatureConfig | undefinedSigning settings for outbound delivery.
retryWebhookRetryOptions | undefinedRetry policy.

Managed per-user outbound secret settings.

FieldTypeDescription
enabledboolean | undefinedWhether managed secrets are enabled.
prefixstring | undefinedSecret name prefix.
bytesint32 | undefinedGenerated secret byte count.

Options accepted by webhooks.out().

FieldTypeDescription
namestringStable outbound webhook instance name.
namespacestring | undefinedPlatform namespace for the instance. Defaults to default.
endpointsWebhookOutboundEndpointOptions[]Destination endpoints.
managedSecretsWebhookManagedSecretOptions | undefinedManaged per-user outbound secret settings.
observabilityLayeron.Observability.ObservabilityConfig | undefinedObservability settings for sends and delivery attempts.

Webhook event record.

FieldTypeDescription
idstringLayeron event id.
directionWebhookDirectionWebhook direction.
namespacestringPlatform namespace for the instance. Defaults to default.
namestringWebhook instance name.
providerstringProvider name.
eventTypestringProvider event type.
externalEventIdstring | undefinedExternal provider event id.
statusWebhookEventStatusProcessing status.
receivedAtstringReceive timestamp.
processedAtstring | undefinedProcessing timestamp.
payloadunknownJSON payload.
headersRecord<string>Captured request headers.

Result returned after handling an inbound webhook.

FieldTypeDescription
statusWebhookEventStatusFinal or queued event status.
eventIdstring | undefinedLayeron event id.
dedupedboolean | undefinedWhether a duplicate event was detected.

Result returned after sending an outbound webhook.

FieldTypeDescription
eventIdstringLayeron event id.
deliveriesunknown[]Endpoint delivery summaries.

Event list filters.

FieldTypeDescription
statusWebhookEventStatus | undefinedStatus filter.
directionWebhookDirection | undefinedDirection filter.
limitint32 | undefinedMaximum events to return.

Event list result.

FieldTypeDescription
eventsWebhookEvent[]Matching events.

Layeron webhooks module returned by webhook helpers.

FieldTypeDescription
name”webhooks”Module name.
configunknownNormalized module configuration.
observabilityLayeron.Observability.ObservabilityConfig | undefinedEffective observability policy recorded on the module declaration.

Signature algorithm used for verification or signing.

ValueDescription
hmac-sha256HMAC signature using SHA-256.
hmac-sha1HMAC signature using SHA-1 for legacy providers.
hmac-sha512HMAC signature using SHA-512.
noneSkip signature verification or signing.

Signature encoding used in headers or query parameters.

ValueDescription
hexHex-encoded signature bytes.
base64Base64-encoded signature bytes.
base64urlBase64url-encoded signature bytes.

Preset used to build the signed payload.

ValueDescription
rawBodySign the raw request body.
timestamp.rawBodySign the timestamp, a dot separator, and the raw request body.
method.path.rawBodySign the HTTP method, path, and raw request body with dot separators.

Webhook direction.

ValueDescription
inboundInbound webhook receiver.
outboundOutbound webhook sender.

Webhook event processing status.

ValueDescription
acceptedThe webhook event was accepted by the ingress path.
duplicateThe webhook event matched an existing dedupe key.
signature_failedSignature verification failed.
queuedThe webhook event was queued for handler execution.
processingThe webhook handler is running.
processedThe webhook handler finished successfully.
failedThe webhook handler or delivery attempt failed.

Webhook placement mode.

ValueDescription
pathExpose the webhook under the app gateway path.
hostExpose the webhook on a dedicated host.

Declare a GitHub inbound webhook receiver.

TypeSpec operation: webhooksGithub.

Terminal window
webhooks.github(options?: WebhookProviderOptions): WebhooksModule

Declare a custom inbound webhook receiver.

TypeSpec operation: webhooksCustom.

Terminal window
webhooks.custom(options: WebhookCustomOptions): WebhooksModule

Declare an outbound webhook sender.

TypeSpec operation: webhooksOutbound.

Terminal window
webhooks.out(options: WebhookOutboundOptions): WebhooksModule

Handle one inbound webhook request.

Terminal window
webhooksHandle(request: unknown): WebhookHandleResult

Send one outbound webhook event.

Terminal window
webhooksSend(eventType: string, payload: unknown): WebhookSendResult

List webhook events.

Terminal window
webhooksListEvents(input?: WebhookListEventsInput): WebhookListEventsResult

Replay one webhook event.

Terminal window
webhooksReplay(eventId: string): WebhookHandleResult