BlueForge Docs

client.webhooks.subscribe

Subscribe to deployment events via SSE.

Signature

class Client {
  webhooks: {
    subscribe(opts: WebhookSubscribeOpts, handler: (event: WebhookEvent) => void): Promise<WebhookSubscription>
  }
}

Parameters

NameTypeRequiredNotes
opts
WebhookSubscribeOpts
yesSubscription options (
events?: string[]
,
filter?: object
)
handler
(event: WebhookEvent) => void
yesEvent 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

ErrorCondition
ApiError
API request failed
NetworkError
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
    keepAlive
    is set in the options
  • Event filtering — use the
    filter
    option to narrow events and reduce unnecessary callback invocations
  • Resource cleanup — always call
    subscription.unsubscribe()
    when the subscription is no longer needed to prevent resource leaks

See also

{auto-injected}

Tested against

{auto-injected}