Skip to content

WebhooksManager

Webhooks management client

Provides methods for managing webhooks to receive real-time event notifications. Webhooks allow your application to be notified when events occur in Fluxbase.

const client = createClient({ url: 'http://localhost:8080' })
await client.auth.login({ email: 'user@example.com', password: 'password' })
// Create a webhook
const webhook = await client.management.webhooks.create({
url: 'https://myapp.com/webhook',
events: ['user.created', 'user.updated'],
secret: 'my-webhook-secret'
})
// Test the webhook
const result = await client.management.webhooks.test(webhook.id)

new WebhooksManager(fetch): WebhooksManager

ParameterType
fetchFluxbaseFetch

WebhooksManager

create(request): Promise<Webhook>

Create a new webhook

ParameterTypeDescription
requestCreateWebhookRequestWebhook configuration

Promise<Webhook>

Created webhook

const webhook = await client.management.webhooks.create({
url: 'https://myapp.com/webhook',
events: ['user.created', 'user.updated', 'user.deleted'],
description: 'User events webhook',
secret: 'my-webhook-secret'
})

delete(webhookId): Promise<DeleteWebhookResponse>

Delete a webhook

ParameterTypeDescription
webhookIdstringWebhook ID

Promise<DeleteWebhookResponse>

Deletion confirmation

await client.management.webhooks.delete('webhook-uuid')
console.log('Webhook deleted')

get(webhookId): Promise<Webhook>

Get a specific webhook by ID

ParameterTypeDescription
webhookIdstringWebhook ID

Promise<Webhook>

Webhook details

const webhook = await client.management.webhooks.get('webhook-uuid')
console.log('Events:', webhook.events)

list(): Promise<ListWebhooksResponse>

List all webhooks for the authenticated user

Promise<ListWebhooksResponse>

List of webhooks

const { webhooks, total } = await client.management.webhooks.list()
webhooks.forEach(webhook => {
console.log(`${webhook.url}: ${webhook.is_active ? 'active' : 'inactive'}`)
})

listDeliveries(webhookId, limit): Promise<ListWebhookDeliveriesResponse>

List webhook delivery history

ParameterTypeDefault valueDescription
webhookIdstringundefinedWebhook ID
limitnumber50Maximum number of deliveries to return (default: 50)

Promise<ListWebhookDeliveriesResponse>

List of webhook deliveries

const { deliveries } = await client.management.webhooks.listDeliveries('webhook-uuid', 100)
deliveries.forEach(delivery => {
console.log(`Event: ${delivery.event}, Status: ${delivery.status_code}`)
})

test(webhookId): Promise<TestWebhookResponse>

Test a webhook by sending a test payload

ParameterTypeDescription
webhookIdstringWebhook ID

Promise<TestWebhookResponse>

Test result with status and response

const result = await client.management.webhooks.test('webhook-uuid')
if (result.success) {
console.log('Webhook test successful')
} else {
console.error('Webhook test failed:', result.error)
}

update(webhookId, updates): Promise<Webhook>

Update a webhook

ParameterTypeDescription
webhookIdstringWebhook ID
updatesUpdateWebhookRequestFields to update

Promise<Webhook>

Updated webhook

const updated = await client.management.webhooks.update('webhook-uuid', {
events: ['user.created', 'user.deleted'],
is_active: false
})