client.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>
| Name | Type | Required | Notes |
|---|---|---|---|
url | string | yes | HTTPS endpoint that will receive deliveries. |
description | string | no | Human-readable label. |
events | WebhookEventType[] | yes | Subscribed event types — see @e-bon/types. |
enabled | boolean | no | Defaults 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>
| Name | Type | Required | Notes |
|---|---|---|---|
id | string | yes | Webhook 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>
| Name | Type | Required | Notes |
|---|---|---|---|
url | string | no | Replace the delivery URL. |
description | string | no | Replace the description. |
events | WebhookEventType[] | no | Replace the subscribed event list. |
enabled | boolean | no | Toggle 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>
| Name | Type | Required | Notes |
|---|---|---|---|
id | string | yes | Webhook 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>
| Name | Type | Required | Notes |
|---|---|---|---|
id | string | yes | Webhook 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.testdelivery and return the delivery record.
async test(id: string): Promise<WebhookDelivery>
| Name | Type | Required | Notes |
|---|---|---|---|
id | string | yes | Webhook 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[]>
| Name | Type | Required | Notes |
|---|---|---|---|
limit | number | no | Page size; server caps the maximum. |
status | WebhookDeliveryStatus | no | Filter 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,
});