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:2230
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:2235
description?stringDescription Description4Players/cortex-typescript-sdk/src/types.ts:2225
eventsstring[]Description Subscribed events4Players/cortex-typescript-sdk/src/types.ts:2221
idstringDescription Subscription ID4Players/cortex-typescript-sdk/src/types.ts:2213
isActivebooleanDescription Whether the subscription is active4Players/cortex-typescript-sdk/src/types.ts:2223
projectIdstringDescription Project/App ID4Players/cortex-typescript-sdk/src/types.ts:2217
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:2215
updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:2240
urlstringDescription Webhook URL4Players/cortex-typescript-sdk/src/types.ts:2219

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:2370

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:2317
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:2329
deliveriesobject[]Description Delivery attempts4Players/cortex-typescript-sdk/src/types.ts:2331
eventTypestringDescription Event type Example message.created4Players/cortex-typescript-sdk/src/types.ts:2308
idstringDescription Event ID4Players/cortex-typescript-sdk/src/types.ts:2299
lastError?stringDescription Last error message4Players/cortex-typescript-sdk/src/types.ts:2319
nextAttemptAtstringFormat: date-time Description Next delivery attempt time4Players/cortex-typescript-sdk/src/types.ts:2324
payloadRecord<string, never>Description Event payload4Players/cortex-typescript-sdk/src/types.ts:2310
projectId?stringDescription Project/App ID4Players/cortex-typescript-sdk/src/types.ts:2303
status"pending" | "delivered" | "failed"Description Delivery status4Players/cortex-typescript-sdk/src/types.ts:2315
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:2301

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:2230
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:2235
description?stringDescription Description4Players/cortex-typescript-sdk/src/types.ts:2225
eventsstring[]Description Subscribed events4Players/cortex-typescript-sdk/src/types.ts:2221
idstringDescription Subscription ID4Players/cortex-typescript-sdk/src/types.ts:2213
isActivebooleanDescription Whether the subscription is active4Players/cortex-typescript-sdk/src/types.ts:2223
projectIdstringDescription Project/App ID4Players/cortex-typescript-sdk/src/types.ts:2217
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:2215
updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:2240
urlstringDescription Webhook URL4Players/cortex-typescript-sdk/src/types.ts:2219

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:2230
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:2235
description?stringDescription Description4Players/cortex-typescript-sdk/src/types.ts:2225
eventsstring[]Description Subscribed events4Players/cortex-typescript-sdk/src/types.ts:2221
idstringDescription Subscription ID4Players/cortex-typescript-sdk/src/types.ts:2213
isActivebooleanDescription Whether the subscription is active4Players/cortex-typescript-sdk/src/types.ts:2223
projectIdstringDescription Project/App ID4Players/cortex-typescript-sdk/src/types.ts:2217
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:2215
updatedAtstringFormat: date-time Description Last update timestamp4Players/cortex-typescript-sdk/src/types.ts:2240
urlstringDescription Webhook URL4Players/cortex-typescript-sdk/src/types.ts:2219

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:2262
createdAtstringFormat: date-time Description Creation timestamp4Players/cortex-typescript-sdk/src/types.ts:2274
eventTypestringDescription Event type Example message.created4Players/cortex-typescript-sdk/src/types.ts:2253
idstringDescription Event ID4Players/cortex-typescript-sdk/src/types.ts:2244
lastError?stringDescription Last error message4Players/cortex-typescript-sdk/src/types.ts:2264
nextAttemptAtstringFormat: date-time Description Next delivery attempt time4Players/cortex-typescript-sdk/src/types.ts:2269
payloadRecord<string, never>Description Event payload4Players/cortex-typescript-sdk/src/types.ts:2255
projectId?stringDescription Project/App ID4Players/cortex-typescript-sdk/src/types.ts:2248
status"pending" | "delivered" | "failed"Description Delivery status4Players/cortex-typescript-sdk/src/types.ts:2260
tenantIdstringDescription Tenant ID4Players/cortex-typescript-sdk/src/types.ts:2246

Defined in

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