WebhookManager
Manages webhook endpoints, their delivery audit trail, and the incoming event listener — client.webhooks.
Manages webhook endpoints, their delivery audit trail, and the incoming event listener — client.webhooks. Registering endpoints (server-side CRUD):
Methods
create()
Register a webhook endpoint (the returned instance carries the secret once).
create(options: CreateWebhookEndpointOptions): Promise<WebhookEndpoint>Parameters
options:CreateWebhookEndpointOptions
Returns Promise<WebhookEndpoint>
list()
List the consumer's webhook endpoints.
list(): Promise<WebhookEndpoint[]>Returns Promise<WebhookEndpoint[]>
fetch()
Get a webhook endpoint by id.
fetch(id: string): Promise<WebhookEndpoint>Parameters
id:string
Returns Promise<WebhookEndpoint>
update()
Update a webhook endpoint (url/description/enabled/eventTypes).
update(id: string, options: UpdateWebhookEndpointOptions): Promise<WebhookEndpoint>Parameters
id:stringoptions:UpdateWebhookEndpointOptions
Returns Promise<WebhookEndpoint>
delete()
Delete a webhook endpoint.
delete(id: string): Promise<WebhookDeletedData>Parameters
id:string
Returns Promise<WebhookDeletedData>
rotateSecret()
Rotate the signing secret (returns a new instance carrying the secret).
rotateSecret(id: string): Promise<WebhookEndpoint>Parameters
id:string
Returns Promise<WebhookEndpoint>
ping()
Send a test event to verify the endpoint.
ping(id: string): Promise<WebhookPingData>Parameters
id:string
Returns Promise<WebhookPingData>
fetchDeliveries()
List delivery attempts for an endpoint (audit trail).
fetchDeliveries(id: string, options?: ListWebhookDeliveriesOptions): Promise<WebhookDeliveryPage>Parameters
id:stringoptions(optional):ListWebhookDeliveriesOptions
Returns Promise<WebhookDeliveryPage>
redeliver()
Manually re-send a past delivery.
redeliver(id: string, deliveryId: string): Promise<WebhookDelivery>Parameters
id:stringdeliveryId:string
Returns Promise<WebhookDelivery>
process()
Verify a raw incoming webhook request and dispatch it to the listeners registered via {@link WebhookManager.on}. Returns the parsed event. Emits, in order: the raw type (PAYMENT_INTENT_SUCCEEDED), the camelCase alias (paymentIntentSucceeded) and the catch-all event.
process(rawBody: string | Uint8Array, signatureHeader: string | null | undefined, options?: WebhookProcessOptions): AnyWebhookEventParameters
rawBody:string | Uint8ArraysignatureHeader:string | null | undefinedoptions(optional):WebhookProcessOptions
Returns AnyWebhookEvent
createHandler()
Build a Node.js http/https request handler that verifies the signature, dispatches the event to your listeners, and replies 200/400.
createHandler(options?: WebhookHandlerOptions): (req: IncomingMessage, res: ServerResponse) => voidParameters
options(optional):WebhookHandlerOptions
Returns (req: IncomingMessage, res: ServerResponse) => void
middleware()
Express-style middleware. Expects the raw body (e.g. mounted with express.raw({ type: '*/*' })). On success it attaches the parsed event to req.cosmosEvent and calls next(); on a bad signature it replies 400.
middleware(options?: WebhookHandlerOptions): (req: RequestLike, res: ResponseLike, next: (err?: unknown) => void) => voidParameters
options(optional):WebhookHandlerOptions
Returns (req: RequestLike, res: ResponseLike, next: (err?: unknown) => void) => void
Related
WebhookEndpoint
A registered webhook endpoint. Note: the signing secret is only ever present on the instance returned by create() / rotateSecret() — list/get responses never…
Client
The main entry point of the SDK — a single, atomic client that exposes every resource through its own manager — an atomic, single-client design.