/** * Webhooks resource client. * * Wraps all /v1/webhooks endpoints: * - create POST /v1/webhooks * - list GET /v1/webhooks * - get GET /v1/webhooks/:id * - update PATCH /v1/webhooks/:id * - delete DELETE /v1/webhooks/:id * - test POST /v1/webhooks/:id/test * - resume POST /v1/webhooks/:id/resume * - listDeliveries GET /v1/webhooks/:id/deliveries * - getDelivery GET /v1/webhooks/:id/deliveries/:deliveryId * - deliveryPages async generator over deliveries * * Requires: `webhook` API key scope for all operations. */ import type { HttpClient, ParsedResponse } from '../http.js'; import type { Webhook, WebhookDelivery, CreateWebhookParams, UpdateWebhookParams, CreateWebhookResult, RotateSecretResult, ListDeliveriesParams } from '../types/webhooks.js'; export declare class WebhooksResource { private readonly http; constructor(http: HttpClient); /** * Create a new webhook subscription. * * **Important:** The raw signing secret is returned once in the response * (`result.data.secret`) and can never be retrieved again. Store it securely * and use it to verify incoming deliveries with `FedPulse.verifyWebhook()`. * * @param params Webhook creation parameters. * @throws {PermissionError} If the API key lacks the `webhook` scope. * @throws {PermissionError} If the plan limit for webhooks has been reached. * * @example * ```ts * const result = await client.webhooks.create({ * url: 'https://my-app.example.com/webhooks/fedpulse', * events: ['opportunity.new', 'opportunity.modified'], * filters: { naics: ['541512'], state: 'VA' }, * }); * const signingSecret = result.data.secret; // Store this securely! * ``` */ create(params: CreateWebhookParams): Promise>; /** * List all webhook subscriptions for the authenticated user. * * @example * ```ts * const webhooks = await client.webhooks.list(); * for (const wh of webhooks.data) { * console.log(wh.id, wh.url, wh.isActive); * } * ``` */ list(): Promise>; /** * Get a single webhook subscription. * * @param id Webhook UUID. * @throws {NotFoundError} If the webhook does not exist or belongs to another user. * * @example * ```ts * const wh = await client.webhooks.get('wh-uuid'); * console.log(wh.data.isActive, wh.data.consecutiveFailures); * ``` */ get(id: string): Promise>; /** * Update a webhook subscription. * * Pass `rotateSecret: true` to generate a new signing secret. * The new secret will be returned in the response. * * @param id Webhook UUID. * @param params Fields to update. At least one non-`rotateSecret` field required. * @throws {NotFoundError} If the webhook does not exist. * @throws {ValidationError} If no update fields are provided. * * @example * ```ts * const updated = await client.webhooks.update('wh-uuid', { * url: 'https://new-endpoint.example.com/webhooks', * events: ['opportunity.new'], * }); * ``` */ update(id: string, params: UpdateWebhookParams): Promise>; /** * Delete a webhook subscription. * * @param id Webhook UUID. * @throws {NotFoundError} If the webhook does not exist. * * @example * ```ts * await client.webhooks.delete('wh-uuid'); * ``` */ delete(id: string): Promise>; /** * Send a test event to a webhook endpoint (synchronous delivery). * * Unlike real deliveries, test events are sent immediately (no queue) and * do not count against the circuit-breaker failure counter. * * @param id Webhook UUID. * @throws {NotFoundError} If the webhook does not exist. * * @example * ```ts * const result = await client.webhooks.test('wh-uuid'); * console.log('Test delivery status:', result.data); * ``` */ test(id: string): Promise>; /** * Resume a paused webhook (clear the circuit-breaker). * * Webhooks are auto-paused after 5 consecutive delivery failures. * Use this to re-enable delivery after fixing the endpoint. * * @param id Webhook UUID. * @throws {NotFoundError} If the webhook does not exist. * * @example * ```ts * await client.webhooks.resume('wh-uuid'); * ``` */ resume(id: string): Promise>; /** * Get paginated delivery history for a webhook. * * @param id Webhook UUID. * @param params Filter and pagination parameters. * @throws {NotFoundError} If the webhook does not exist. * * @example * ```ts * const deliveries = await client.webhooks.listDeliveries('wh-uuid', { * status: 'failed', * limit: 50, * }); * ``` */ listDeliveries(id: string, params?: ListDeliveriesParams): Promise>; /** * Get the full detail of a single webhook delivery, including the payload. * * @param id Webhook UUID. * @param deliveryId Delivery UUID. * @throws {NotFoundError} If the webhook or delivery does not exist. * * @example * ```ts * const delivery = await client.webhooks.getDelivery('wh-uuid', 'del-uuid'); * console.log('Payload:', delivery.data.payload); * ``` */ getDelivery(id: string, deliveryId: string): Promise>; /** * Async generator that automatically paginates through delivery history. * * @param id Webhook UUID. * @param params Same filter parameters as `listDeliveries()`. Do not pass `page`. * * @example * ```ts * for await (const page of client.webhooks.deliveryPages('wh-uuid', { status: 'failed' })) { * for (const delivery of page.data) { * console.log(delivery.id, delivery.status, delivery.httpStatus); * } * } * ``` */ deliveryPages(id: string, params?: Omit): AsyncGenerator>; } //# sourceMappingURL=webhooks.d.ts.map