import { APIResource } from "../core/resource.mjs"; import * as FilesAPI from "./files.mjs"; import * as SourcesAPI from "./sources.mjs"; import * as UploadsAPI from "./uploads.mjs"; import * as JobsAPI from "./jobs/jobs.mjs"; import { APIPromise } from "../core/api-promise.mjs"; import { RequestOptions } from "../internal/request-options.mjs"; export declare class Webhooks extends APIResource { /** * Create a new webhook for a project. The webhook will receive notifications for * specified events. * * @example * ```ts * const webhook = await client.webhooks.create({ * url: 'https://example.com/webhook', * }); * ``` */ create(body: WebhookCreateParams, options?: RequestOptions): APIPromise; /** * Retrieve details of a specific webhook configuration by its ID. The webhook must * belong to the current project. * * @example * ```ts * const webhook = await client.webhooks.retrieve('webhookId'); * ``` */ retrieve(webhookID: string, options?: RequestOptions): APIPromise; /** * Update the enabled status of a webhook. The webhook must belong to the current * project. * * @example * ```ts * await client.webhooks.update('webhookId'); * ``` */ update(webhookID: string, body: WebhookUpdateParams, options?: RequestOptions): APIPromise; /** * Retrieve a list of all webhooks configured for the current project. Each webhook * includes its URL, enabled status, and subscribed events. * * @example * ```ts * const webhooks = await client.webhooks.list(); * ``` */ list(options?: RequestOptions): APIPromise; /** * Permanently delete a webhook configuration. The webhook must belong to the * current project. This action cannot be undone. * * @example * ```ts * await client.webhooks.delete('webhookId'); * ``` */ delete(webhookID: string, options?: RequestOptions): APIPromise; unwrap(body: string, { headers, key }: { headers: Record; key?: string; }): UnwrapWebhookEvent; } export interface Webhook { /** * Unique identifier of the webhook */ id: string; /** * Whether the webhook is currently enabled */ enabled: boolean; /** * Array of event types this webhook subscribes to */ events: Array<'job.completed' | 'job.failed' | 'job.cancelled' | 'upload.completed' | 'upload.failed' | 'upload.expired'>; /** * ID of the project this webhook belongs to */ project_id: string; /** * URL where webhook events will be sent */ url: string; } /** * Response containing the list of all webhooks for a project */ export interface WebhookListResponse { /** * Data contains the webhook items */ data: Array; /** * Status indicates the response status "success" */ status: 'success'; } export interface NewEventWebhookEvent { /** * Unique identifier of the notification */ id: string; /** * Event-specific payload data */ data: NewEventWebhookEvent.NotificationPayloadJobCompleted | NewEventWebhookEvent.NotificationPayloadJobFailed | NewEventWebhookEvent.NotificationPayloadUploadCompleted | NewEventWebhookEvent.NotificationPayloadUploadFailed; /** * Timestamp when the notification was sent */ date: string; /** * Type of event that triggered the notification. */ event: 'job.completed' | 'job.failed' | 'job.cancelled' | 'upload.completed' | 'upload.failed' | 'upload.expired'; } export declare namespace NewEventWebhookEvent { /** * Payload data structure for job.completed events */ interface NotificationPayloadJobCompleted { /** * List of files generated by the job */ files: Array; job: JobsAPI.Job; } /** * Payload data structure for job.failed and job.cancelled events */ interface NotificationPayloadJobFailed { job: JobsAPI.Job; } /** * Payload data structure for upload.completed events */ interface NotificationPayloadUploadCompleted { source: SourcesAPI.Source; upload: UploadsAPI.Upload; } /** * Payload data structure for upload.failed and upload.expired events */ interface NotificationPayloadUploadFailed { upload: UploadsAPI.Upload; } } export interface UnwrapWebhookEvent { /** * Unique identifier of the notification */ id: string; /** * Event-specific payload data */ data: UnwrapWebhookEvent.NotificationPayloadJobCompleted | UnwrapWebhookEvent.NotificationPayloadJobFailed | UnwrapWebhookEvent.NotificationPayloadUploadCompleted | UnwrapWebhookEvent.NotificationPayloadUploadFailed; /** * Timestamp when the notification was sent */ date: string; /** * Type of event that triggered the notification. */ event: 'job.completed' | 'job.failed' | 'job.cancelled' | 'upload.completed' | 'upload.failed' | 'upload.expired'; } export declare namespace UnwrapWebhookEvent { /** * Payload data structure for job.completed events */ interface NotificationPayloadJobCompleted { /** * List of files generated by the job */ files: Array; job: JobsAPI.Job; } /** * Payload data structure for job.failed and job.cancelled events */ interface NotificationPayloadJobFailed { job: JobsAPI.Job; } /** * Payload data structure for upload.completed events */ interface NotificationPayloadUploadCompleted { source: SourcesAPI.Source; upload: UploadsAPI.Upload; } /** * Payload data structure for upload.failed and upload.expired events */ interface NotificationPayloadUploadFailed { upload: UploadsAPI.Upload; } } export interface WebhookCreateParams { /** * Url is the endpoint that will receive webhook notifications, which must be a * valid HTTP URL. */ url: string; /** * Enabled indicates whether the webhook is active. */ enabled?: boolean; /** * Events specifies the types of events that will trigger the webhook. */ events?: Array<'job.completed' | 'job.failed' | 'job.cancelled' | 'upload.completed' | 'upload.failed' | 'upload.expired'>; } export interface WebhookUpdateParams { /** * Enabled indicates whether the webhook should be enabled or disabled. */ enabled?: boolean; /** * Events specifies the types of events that will trigger the webhook. */ events?: Array<'job.completed' | 'job.failed' | 'job.cancelled' | 'upload.completed' | 'upload.failed' | 'upload.expired'>; } export declare namespace Webhooks { export { type Webhook as Webhook, type WebhookListResponse as WebhookListResponse, type NewEventWebhookEvent as NewEventWebhookEvent, type UnwrapWebhookEvent as UnwrapWebhookEvent, type WebhookCreateParams as WebhookCreateParams, type WebhookUpdateParams as WebhookUpdateParams, }; } //# sourceMappingURL=webhooks.d.mts.map