e-bon
e-bon.ro
TypeScript SDK

client.webhooks

Reference for the WebhooksResource — manage webhook subscriptions, rotate signing secrets, fire test deliveries and inspect delivery history, mirroring /api/v1/org/webhooks.

client.webhooks

client.webhooks wraps /api/v1/org/webhooks/* — webhook subscription management, signing-secret rotation, synchronous test deliveries and per-webhook delivery history. See the matching REST documentation at Webhooks API and the event payload catalogue at Webhook events.

HTTP-level failures surface as EBonApiError — see Errors and /en/api/errors.

client.webhooks.list()

List all webhooks for the organization. Secrets are never returned.

async list(): Promise<Webhook[]>

No parameters. Returns an array of Webhook. (The SDK unwraps the { webhooks } envelope.)

const webhooks = await client.webhooks.list();

client.webhooks.create(body)

Create a new webhook subscription.

The returned object includes the raw signing secret — store it securely, it is returned only once.

async create(body: CreateWebhookBody): Promise<CreateWebhookResult>
NameTypeRequiredNotes
urlstringyesHTTPS endpoint that will receive deliveries.
descriptionstringnoHuman-readable label.
eventsWebhookEventType[]yesSubscribed event types — see @e-bon/types.
enabledbooleannoDefaults to true server-side.

Returns Webhook & { secret: string }. (The SDK unwraps the { webhook } envelope.) The raw secret is shown once.

const created = await client.webhooks.create({
  url: 'https://example.com/ebon-hook',
  events: ['receipt.created', 'command.failed'],
});
console.log(created.secret); // store it!

client.webhooks.get(id)

Get a single webhook by ID (without secret).

async get(id: string): Promise<Webhook>
NameTypeRequiredNotes
idstringyesWebhook identifier.

Returns a single Webhook. (The SDK unwraps the { webhook } envelope.)

const webhook = await client.webhooks.get('wh_01HZ...');

client.webhooks.update(id, body)

Update a webhook's url, description, events, or enabled flag.

async update(id: string, body: UpdateWebhookBody): Promise<Webhook>
NameTypeRequiredNotes
urlstringnoReplace the delivery URL.
descriptionstringnoReplace the description.
eventsWebhookEventType[]noReplace the subscribed event list.
enabledbooleannoToggle delivery on/off.

Returns the updated Webhook.

await client.webhooks.update('wh_01HZ...', { enabled: false });

client.webhooks.delete(id)

Permanently delete a webhook and all of its delivery records.

async delete(id: string): Promise<undefined>
NameTypeRequiredNotes
idstringyesWebhook identifier.

Returns undefined on success.

await client.webhooks.delete('wh_01HZ...');

client.webhooks.rotateSecret(id)

Rotate the signing secret. Returns the new raw secret (shown only once).

async rotateSecret(id: string): Promise<RotateWebhookSecretResult>
NameTypeRequiredNotes
idstringyesWebhook identifier.

Returns { secret: string }. The previous secret continues to validate signatures during a brief overlap window — see Webhooks API › Rotation.

const { secret } = await client.webhooks.rotateSecret('wh_01HZ...');

client.webhooks.test(id)

Fire a synchronous webhook.test delivery and return the delivery record.

async test(id: string): Promise<WebhookDelivery>
NameTypeRequiredNotes
idstringyesWebhook identifier.

Returns a single WebhookDelivery describing the response from your endpoint. (The SDK unwraps the { delivery } envelope.)

const delivery = await client.webhooks.test('wh_01HZ...');
console.log(delivery.status, delivery.responseStatus);

client.webhooks.listDeliveries(id, query?)

List recent delivery attempts for a webhook (newest first).

async listDeliveries(id: string, query?: ListWebhookDeliveriesQuery): Promise<WebhookDelivery[]>
NameTypeRequiredNotes
limitnumbernoPage size; server caps the maximum.
statusWebhookDeliveryStatusnoFilter by delivery status.

Returns an array of WebhookDelivery. (The SDK unwraps the { deliveries } envelope.)

const recent = await client.webhooks.listDeliveries('wh_01HZ...', {
  status: 'failed',
  limit: 50,
});