WebhooksAPI
Defined in: v1/webhooks.ts:20
Handles all webhook-related API operations. Intended to be instantiated by a parent API client that provides the base fetch logic.
Remarks
Section titled “Remarks”These endpoints are read-only. Creating, updating, or deleting webhooks is not supported in this SDK.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new WebhooksAPI(
baseFetch):WebhooksAPI
Defined in: v1/webhooks.ts:29
Creates a new WebhooksAPI instance.
Parameters
Section titled “Parameters”baseFetch
Section titled “baseFetch”<T>(endpoint, schema) => Promise<T>
A generic fetch function provided by the parent client. Handles request execution and response validation against a Zod schema.
Returns
Section titled “Returns”WebhooksAPI
Example
Section titled “Example”const webhooks = new WebhooksAPI((endpoint, schema) => myClient.fetch(endpoint, schema));Methods
Section titled “Methods”getEvents()
Section titled “getEvents()”getEvents(
webhookId,page?,per?,filters?):Promise<{events: {attempt_count?:number;created_at:string;id:number;last_attempted_at?:string|null;object_id?:number;object_type?:string;response_http_status?:number|null;webhook_id:number;workflow_state?:string; }[];meta?: {from?:number;number_of_pages?:number;page?:number;per_page?:number;to?:number;total?:number; }; }>
Defined in: v1/webhooks.ts:63
Retrieves a paginated list of delivery events for a specific webhook, with optional filters for HTTP status range and creation date.
Parameters
Section titled “Parameters”webhookId
Section titled “webhookId”number
The unique identifier of the webhook.
number = 1
The page number to retrieve. Defaults to 1.
number = 20
The number of results per page. Defaults to 20, maximum: 100.
filters?
Section titled “filters?”Optional filters to narrow the results.
createdAfter?
Section titled “createdAfter?”string
Return only events created after this date (ISO 8601).
createdBefore?
Section titled “createdBefore?”string
Return only events created before this date (ISO 8601).
responseHttpStatusGte?
Section titled “responseHttpStatusGte?”number
Return only events with an HTTP status >= this value.
responseHttpStatusLte?
Section titled “responseHttpStatusLte?”number
Return only events with an HTTP status <= this value.
Returns
Section titled “Returns”Promise<{ events: { attempt_count?: number; created_at: string; id: number; last_attempted_at?: string | null; object_id?: number; object_type?: string; response_http_status?: number | null; webhook_id: number; workflow_state?: string; }[]; meta?: { from?: number; number_of_pages?: number; page?: number; per_page?: number; to?: number; total?: number; }; }>
A promise resolving to a validated WebhookEventsResponse object.
Throws
Section titled “Throws”If no webhook exists with the given ID or the request fails.
Example
Section titled “Example”// All events for a webhookconst { events } = await webhooksAPI.getEvents(42);
// Only failed events (HTTP 4xx/5xx)const { events } = await webhooksAPI.getEvents(42, 1, 20, { responseHttpStatusGte: 400,});getList()
Section titled “getList()”getList():
Promise<{webhooks: {event_trigger?:string;id:number;url?:string;webhook_events_count?:number;workflow_state?:string; }[]; }>
Defined in: v1/webhooks.ts:37
Retrieves all webhooks registered on the Teachable school.
Returns
Section titled “Returns”Promise<{ webhooks: { event_trigger?: string; id: number; url?: string; webhook_events_count?: number; workflow_state?: string; }[]; }>
A promise resolving to a validated WebhooksResponse object.
Example
Section titled “Example”const { webhooks } = await webhooksAPI.getList();