client.webhooks.subscribe
Subscribe to deployment events via SSE.
Signature
class Client {
webhooks: {
subscribe(opts: WebhookSubscribeOpts, handler: (event: WebhookEvent) => void): Promise<WebhookSubscription>
}
}
Parameters
| Name | Type | Required | Notes |
|---|---|---|---|
| | yes | Subscription options (, ) |
| | yes | Event callback |
Examples
import { Client } from '@blueforge/client'
const bf = new Client({ apiKey: process.env.BF_API_KEY!, url: 'https://your-project.blueforge.dev' })
const sub = await bf.webhooks.subscribe(
{ events: ['deployment.complete'] },
(event) => console.log(event)
)
// Later: sub.unsubscribe()
Throws
| Error | Condition |
|---|---|
| API request failed |
| Network issue |
Pitfalls
- SSE connections — ensure the client environment supports HTTP/2 or configure a long-polling fallback for older infrastructure
- Auto-termination — the subscription automatically terminates on client disconnect unless
is set in the optionskeepAlive - Event filtering — use the
option to narrow events and reduce unnecessary callback invocationsfilter - Resource cleanup — always call
when the subscription is no longer needed to prevent resource leakssubscription.unsubscribe()
See also
{auto-injected}
Tested against
{auto-injected}