Skip to main content

Class: WebhookManager

Manages webhook subscriptions and events for a project.

Constructors

new WebhookManager()

new WebhookManager(ctx, projectId): WebhookManager

Internal

Parameters

ParameterType
ctxClientContext
projectIdstring

Returns

WebhookManager

Defined in

4Players/cortex-typescript-sdk/src/resources/webhooks.ts:29

Methods

createSubscription()

createSubscription(body): Promise<object>

Create a webhook subscription

Parameters

ParameterTypeDescription
bodyobjectWebhook subscription payload
body.apiKey?stringDescription API key value (for api_key auth) Example sk_live_xxx
body.apiKeyHeader?stringDescription Header name to send the API key in (for api_key auth). Defaults to 'X-API-Key' if omitted. Example X-API-Key
body.authType?"none" | "api_key" | "basic_auth" | "custom_headers"Description How Cortex authenticates when POSTing to your webhook URL. Defaults to 'none' if omitted.
body.basicAuthPassword?stringDescription Basic auth password
body.basicAuthUsername?stringDescription Basic auth username
body.customHeaders?objectDescription Custom headers to send with webhook requests Example { * "X-Custom-Header": "value" * }
body.description?stringDescription Description of this webhook Example Production webhook endpoint
body.eventsstring[]Description List of events to subscribe to. Supports wildcards like "message." or "" Example [ "session.created", "message.*" ]
body.secretstringDescription Secret for HMAC-SHA256 signature verification Example my_secret_key
body.urlstringDescription Webhook URL Example https://example.com/webhook

Returns

Promise<object>

Created subscription

NameTypeDescriptionDefined in
authType"none" | "api_key" | "basic_auth" | "custom_headers"Description Authentication type4Players/cortex-typescript-sdk/src/types.ts:1982
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:1987
description?stringDescription Description4Players/cortex-typescript-sdk/src/types.ts:1977
eventsstring[]Description Subscribed events4Players/cortex-typescript-sdk/src/types.ts:1973
idstringDescription Subscription ID4Players/cortex-typescript-sdk/src/types.ts:1965
isActivebooleanDescription Whether the subscription is active4Players/cortex-typescript-sdk/src/types.ts:1975
projectIdstringDescription Project/App ID4Players/cortex-typescript-sdk/src/types.ts:1969
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:1967
updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:1992
urlstringDescription Webhook URL4Players/cortex-typescript-sdk/src/types.ts:1971

Defined in

4Players/cortex-typescript-sdk/src/resources/webhooks.ts:52


deleteSubscription()

deleteSubscription(subscriptionId): Promise<object>

Delete a webhook subscription

Parameters

ParameterTypeDescription
subscriptionIdstringSubscription ID

Returns

Promise<object>

Deletion confirmation

NameTypeDescriptionDefined in
messagestringDescription Status message Example Subscription deleted4Players/cortex-typescript-sdk/src/types.ts:2128

Defined in

4Players/cortex-typescript-sdk/src/resources/webhooks.ts:95


getEvent()

getEvent(eventId): Promise<object>

Get webhook event details including delivery attempts

Parameters

ParameterTypeDescription
eventIdstringEvent ID

Returns

Promise<object>

Event details with deliveries

NameTypeDescriptionDefined in
attemptsCountnumberDescription Number of delivery attempts4Players/cortex-typescript-sdk/src/types.ts:2075
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:2087
deliveriesobject[]Description Delivery attempts4Players/cortex-typescript-sdk/src/types.ts:2089
eventTypestringDescription Event type Example message.created4Players/cortex-typescript-sdk/src/types.ts:2064
idstringDescription Event ID4Players/cortex-typescript-sdk/src/types.ts:2055
lastError?stringDescription Last error message4Players/cortex-typescript-sdk/src/types.ts:2077
nextAttemptAtstringFormat: date-time Description Next delivery attempt time4Players/cortex-typescript-sdk/src/types.ts:2082
payloadobjectDescription Event payload4Players/cortex-typescript-sdk/src/types.ts:2066
projectId?stringDescription Project/App ID4Players/cortex-typescript-sdk/src/types.ts:2059
status"pending" | "delivered" | "failed"Description Delivery status4Players/cortex-typescript-sdk/src/types.ts:2073
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:2057

Defined in

4Players/cortex-typescript-sdk/src/resources/webhooks.ts:123


getSubscription()

getSubscription(subscriptionId): Promise<object>

Get a webhook subscription by ID

Parameters

ParameterTypeDescription
subscriptionIdstringSubscription ID

Returns

Promise<object>

Subscription details

NameTypeDescriptionDefined in
authType"none" | "api_key" | "basic_auth" | "custom_headers"Description Authentication type4Players/cortex-typescript-sdk/src/types.ts:1982
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:1987
description?stringDescription Description4Players/cortex-typescript-sdk/src/types.ts:1977
eventsstring[]Description Subscribed events4Players/cortex-typescript-sdk/src/types.ts:1973
idstringDescription Subscription ID4Players/cortex-typescript-sdk/src/types.ts:1965
isActivebooleanDescription Whether the subscription is active4Players/cortex-typescript-sdk/src/types.ts:1975
projectIdstringDescription Project/App ID4Players/cortex-typescript-sdk/src/types.ts:1969
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:1967
updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:1992
urlstringDescription Webhook URL4Players/cortex-typescript-sdk/src/types.ts:1971

Defined in

4Players/cortex-typescript-sdk/src/resources/webhooks.ts:66


listEvents()

listEvents(query?): Promise<object[]>

List webhook events

Parameters

ParameterTypeDescription
query?objectOptional filters (status, limit, offset)
query.limit?numberDescription Items to return
query.offset?numberDescription Items to skip
query.status?"pending" | "delivered" | "failed"Description Filter by delivery status

Returns

Promise<object[]>

Array of webhook events

Defined in

4Players/cortex-typescript-sdk/src/resources/webhooks.ts:109


listSubscriptions()

listSubscriptions(): Promise<object[]>

List webhook subscriptions

Returns

Promise<object[]>

Array of webhook subscriptions

Defined in

4Players/cortex-typescript-sdk/src/resources/webhooks.ts:38


updateSubscription()

updateSubscription(subscriptionId, body): Promise<object>

Update a webhook subscription

Parameters

ParameterTypeDescription
subscriptionIdstringSubscription ID
bodyobjectUpdated subscription data
body.apiKey?stringDescription API key value
body.apiKeyHeader?stringDescription API key header name
body.authType?"none" | "api_key" | "basic_auth" | "custom_headers"Description Authentication type
body.basicAuthPassword?stringDescription Basic auth password
body.basicAuthUsername?stringDescription Basic auth username
body.customHeaders?objectDescription Custom headers
body.description?stringDescription Description of this webhook
body.events?string[]Description List of events to subscribe to
body.isActive?booleanDescription Whether the subscription is active
body.secret?stringDescription Secret for HMAC-SHA256 signature verification
body.url?stringDescription Webhook URL Example https://example.com/webhook

Returns

Promise<object>

Updated subscription

NameTypeDescriptionDefined in
authType"none" | "api_key" | "basic_auth" | "custom_headers"Description Authentication type4Players/cortex-typescript-sdk/src/types.ts:1982
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:1987
description?stringDescription Description4Players/cortex-typescript-sdk/src/types.ts:1977
eventsstring[]Description Subscribed events4Players/cortex-typescript-sdk/src/types.ts:1973
idstringDescription Subscription ID4Players/cortex-typescript-sdk/src/types.ts:1965
isActivebooleanDescription Whether the subscription is active4Players/cortex-typescript-sdk/src/types.ts:1975
projectIdstringDescription Project/App ID4Players/cortex-typescript-sdk/src/types.ts:1969
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:1967
updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:1992
urlstringDescription Webhook URL4Players/cortex-typescript-sdk/src/types.ts:1971

Defined in

4Players/cortex-typescript-sdk/src/resources/webhooks.ts:81


watchEvents()

watchEvents(query?): CollectionSubscription<object>

Live-subscribe to the webhook event log (the outbox of domain events queued for webhook delivery). The initial page is loaded via REST, then kept in sync over SSE from webhook.delivery.updated events: each one updates the matching event's delivery status / attemptsCount / lastError in place, or inserts the event if it isn't in the list yet (e.g. a freshly-queued event on its first delivery attempt).

Note: the backend has no dedicated "webhook event created" event — a new outbox row only becomes visible here once it is first attempted (which emits webhook.delivery.updated), or on the next reconnect resync.

Parameters

ParameterTypeDescription
query?objectOptional initial-snapshot filters (status, limit, offset). For combined live + filtering, prefer fetching unfiltered and filtering client-side, since live upserts are not re-filtered.
query.limit?numberDescription Items to return
query.offset?numberDescription Items to skip
query.status?"pending" | "delivered" | "failed"Description Filter by delivery status

Returns

CollectionSubscription<object>

A CollectionSubscription of webhook events.

NameTypeDescriptionDefined in
attemptsCountnumberDescription Number of delivery attempts4Players/cortex-typescript-sdk/src/types.ts:2016
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:2028
eventTypestringDescription Event type Example message.created4Players/cortex-typescript-sdk/src/types.ts:2005
idstringDescription Event ID4Players/cortex-typescript-sdk/src/types.ts:1996
lastError?stringDescription Last error message4Players/cortex-typescript-sdk/src/types.ts:2018
nextAttemptAtstringFormat: date-time Description Next delivery attempt time4Players/cortex-typescript-sdk/src/types.ts:2023
payloadobjectDescription Event payload4Players/cortex-typescript-sdk/src/types.ts:2007
projectId?stringDescription Project/App ID4Players/cortex-typescript-sdk/src/types.ts:2000
status"pending" | "delivered" | "failed"Description Delivery status4Players/cortex-typescript-sdk/src/types.ts:2014
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:1998

Defined in

4Players/cortex-typescript-sdk/src/resources/webhooks.ts:149