Class: WebhookManager
Manages webhook subscriptions and events for a project.
Constructors
new WebhookManager()
Internal
Parameters
| Parameter | Type |
|---|---|
ctx | ClientContext |
projectId | string |
Returns
Defined in
4Players/cortex-typescript-sdk/src/resources/webhooks.ts:29
Methods
createSubscription()
Create a webhook subscription
Parameters
| Parameter | Type | Description |
|---|---|---|
body | object | Webhook subscription payload |
body.apiKey? | string | Description API key value (for api_key auth) Example sk_live_xxx |
body.apiKeyHeader? | string | Description 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? | string | Description Basic auth password |
body.basicAuthUsername? | string | Description Basic auth username |
body.customHeaders? | object | Description Custom headers to send with webhook requests Example { * "X-Custom-Header": "value" * } |
body.description? | string | Description Description of this webhook Example Production webhook endpoint |
body.events | string[] | Description List of events to subscribe to. Supports wildcards like "message." or "" Example [ "session.created", "message.*" ] |
body.secret | string | Description Secret for HMAC-SHA256 signature verification Example my_secret_key |
body.url | string | Description Webhook URL Example https://example.com/webhook |
Returns
Promise<object>
Created subscription
| Name | Type | Description | Defined in |
|---|---|---|---|
authType | "none" | "api_key" | "basic_auth" | "custom_headers" | Description Authentication type | 4Players/cortex-typescript-sdk/src/types.ts:2230 |
createdAt | string | Format: date-time Description Creation timestamp | 4Players/cortex-typescript-sdk/src/types.ts:2235 |
description? | string | Description Description | 4Players/cortex-typescript-sdk/src/types.ts:2225 |
events | string[] | Description Subscribed events | 4Players/cortex-typescript-sdk/src/types.ts:2221 |
id | string | Description Subscription ID | 4Players/cortex-typescript-sdk/src/types.ts:2213 |
isActive | boolean | Description Whether the subscription is active | 4Players/cortex-typescript-sdk/src/types.ts:2223 |
projectId | string | Description Project/App ID | 4Players/cortex-typescript-sdk/src/types.ts:2217 |
tenantId | string | Description Tenant ID | 4Players/cortex-typescript-sdk/src/types.ts:2215 |
updatedAt | string | Format: date-time Description Last update timestamp | 4Players/cortex-typescript-sdk/src/types.ts:2240 |
url | string | Description Webhook URL | 4Players/cortex-typescript-sdk/src/types.ts:2219 |
Defined in
4Players/cortex-typescript-sdk/src/resources/webhooks.ts:52
deleteSubscription()
Delete a webhook subscription
Parameters
| Parameter | Type | Description |
|---|---|---|
subscriptionId | string | Subscription ID |
Returns
Promise<object>
Deletion confirmation
| Name | Type | Description | Defined in |
|---|---|---|---|
message | string | Description Status message Example Subscription deleted | 4Players/cortex-typescript-sdk/src/types.ts:2370 |
Defined in
4Players/cortex-typescript-sdk/src/resources/webhooks.ts:95
getEvent()
Get webhook event details including delivery attempts
Parameters
| Parameter | Type | Description |
|---|---|---|
eventId | string | Event ID |
Returns
Promise<object>
Event details with deliveries
| Name | Type | Description | Defined in |
|---|---|---|---|
attemptsCount | number | Description Number of delivery attempts | 4Players/cortex-typescript-sdk/src/types.ts:2317 |
createdAt | string | Format: date-time Description Creation timestamp | 4Players/cortex-typescript-sdk/src/types.ts:2329 |
deliveries | object[] | Description Delivery attempts | 4Players/cortex-typescript-sdk/src/types.ts:2331 |
eventType | string | Description Event type Example message.created | 4Players/cortex-typescript-sdk/src/types.ts:2308 |
id | string | Description Event ID | 4Players/cortex-typescript-sdk/src/types.ts:2299 |
lastError? | string | Description Last error message | 4Players/cortex-typescript-sdk/src/types.ts:2319 |
nextAttemptAt | string | Format: date-time Description Next delivery attempt time | 4Players/cortex-typescript-sdk/src/types.ts:2324 |
payload | Record<string, never> | Description Event payload | 4Players/cortex-typescript-sdk/src/types.ts:2310 |
projectId? | string | Description Project/App ID | 4Players/cortex-typescript-sdk/src/types.ts:2303 |
status | "pending" | "delivered" | "failed" | Description Delivery status | 4Players/cortex-typescript-sdk/src/types.ts:2315 |
tenantId | string | Description Tenant ID | 4Players/cortex-typescript-sdk/src/types.ts:2301 |
Defined in
4Players/cortex-typescript-sdk/src/resources/webhooks.ts:123
getSubscription()
Get a webhook subscription by ID
Parameters
| Parameter | Type | Description |
|---|---|---|
subscriptionId | string | Subscription ID |
Returns
Promise<object>
Subscription details
| Name | Type | Description | Defined in |
|---|---|---|---|
authType | "none" | "api_key" | "basic_auth" | "custom_headers" | Description Authentication type | 4Players/cortex-typescript-sdk/src/types.ts:2230 |
createdAt | string | Format: date-time Description Creation timestamp | 4Players/cortex-typescript-sdk/src/types.ts:2235 |
description? | string | Description Description | 4Players/cortex-typescript-sdk/src/types.ts:2225 |
events | string[] | Description Subscribed events | 4Players/cortex-typescript-sdk/src/types.ts:2221 |
id | string | Description Subscription ID | 4Players/cortex-typescript-sdk/src/types.ts:2213 |
isActive | boolean | Description Whether the subscription is active | 4Players/cortex-typescript-sdk/src/types.ts:2223 |
projectId | string | Description Project/App ID | 4Players/cortex-typescript-sdk/src/types.ts:2217 |
tenantId | string | Description Tenant ID | 4Players/cortex-typescript-sdk/src/types.ts:2215 |
updatedAt | string | Format: date-time Description Last update timestamp | 4Players/cortex-typescript-sdk/src/types.ts:2240 |
url | string | Description Webhook URL | 4Players/cortex-typescript-sdk/src/types.ts:2219 |
Defined in
4Players/cortex-typescript-sdk/src/resources/webhooks.ts:66
listEvents()
List webhook events
Parameters
| Parameter | Type | Description |
|---|---|---|
query? | object | Optional filters (status, limit, offset) |
query.limit? | number | Description Items to return |
query.offset? | number | Description 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()
List webhook subscriptions
Returns
Promise<object[]>
Array of webhook subscriptions
Defined in
4Players/cortex-typescript-sdk/src/resources/webhooks.ts:38
updateSubscription()
Update a webhook subscription
Parameters
| Parameter | Type | Description |
|---|---|---|
subscriptionId | string | Subscription ID |
body | object | Updated subscription data |
body.apiKey? | string | Description API key value |
body.apiKeyHeader? | string | Description API key header name |
body.authType? | "none" | "api_key" | "basic_auth" | "custom_headers" | Description Authentication type |
body.basicAuthPassword? | string | Description Basic auth password |
body.basicAuthUsername? | string | Description Basic auth username |
body.customHeaders? | object | Description Custom headers |
body.description? | string | Description Description of this webhook |
body.events? | string[] | Description List of events to subscribe to |
body.isActive? | boolean | Description Whether the subscription is active |
body.secret? | string | Description Secret for HMAC-SHA256 signature verification |
body.url? | string | Description Webhook URL Example https://example.com/webhook |
Returns
Promise<object>
Updated subscription
| Name | Type | Description | Defined in |
|---|---|---|---|
authType | "none" | "api_key" | "basic_auth" | "custom_headers" | Description Authentication type | 4Players/cortex-typescript-sdk/src/types.ts:2230 |
createdAt | string | Format: date-time Description Creation timestamp | 4Players/cortex-typescript-sdk/src/types.ts:2235 |
description? | string | Description Description | 4Players/cortex-typescript-sdk/src/types.ts:2225 |
events | string[] | Description Subscribed events | 4Players/cortex-typescript-sdk/src/types.ts:2221 |
id | string | Description Subscription ID | 4Players/cortex-typescript-sdk/src/types.ts:2213 |
isActive | boolean | Description Whether the subscription is active | 4Players/cortex-typescript-sdk/src/types.ts:2223 |
projectId | string | Description Project/App ID | 4Players/cortex-typescript-sdk/src/types.ts:2217 |
tenantId | string | Description Tenant ID | 4Players/cortex-typescript-sdk/src/types.ts:2215 |
updatedAt | string | Format: date-time Description Last update timestamp | 4Players/cortex-typescript-sdk/src/types.ts:2240 |
url | string | Description Webhook URL | 4Players/cortex-typescript-sdk/src/types.ts:2219 |
Defined in
4Players/cortex-typescript-sdk/src/resources/webhooks.ts:81
watchEvents()
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
| Parameter | Type | Description |
|---|---|---|
query? | object | Optional 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? | number | Description Items to return |
query.offset? | number | Description Items to skip |
query.status? | "pending" | "delivered" | "failed" | Description Filter by delivery status |
Returns
CollectionSubscription<object>
A CollectionSubscription of webhook events.
| Name | Type | Description | Defined in |
|---|---|---|---|
attemptsCount | number | Description Number of delivery attempts | 4Players/cortex-typescript-sdk/src/types.ts:2262 |
createdAt | string | Format: date-time Description Creation timestamp | 4Players/cortex-typescript-sdk/src/types.ts:2274 |
eventType | string | Description Event type Example message.created | 4Players/cortex-typescript-sdk/src/types.ts:2253 |
id | string | Description Event ID | 4Players/cortex-typescript-sdk/src/types.ts:2244 |
lastError? | string | Description Last error message | 4Players/cortex-typescript-sdk/src/types.ts:2264 |
nextAttemptAt | string | Format: date-time Description Next delivery attempt time | 4Players/cortex-typescript-sdk/src/types.ts:2269 |
payload | Record<string, never> | Description Event payload | 4Players/cortex-typescript-sdk/src/types.ts:2255 |
projectId? | string | Description Project/App ID | 4Players/cortex-typescript-sdk/src/types.ts:2248 |
status | "pending" | "delivered" | "failed" | Description Delivery status | 4Players/cortex-typescript-sdk/src/types.ts:2260 |
tenantId | string | Description Tenant ID | 4Players/cortex-typescript-sdk/src/types.ts:2246 |
Defined in
4Players/cortex-typescript-sdk/src/resources/webhooks.ts:149