Skip to main content
The methods on this page require SDK 2.0.0 or later, where WebhookService uses the Paubox webhooks service and a scoped API key.
WebhookService manages webhook endpoints through the Paubox webhooks service at https://api.paubox.com/v1/webhooks. It sends a scoped API key as Authorization: Bearer YOUR_API_KEY. The key’s scopes decide which events it can subscribe to.

Create the service

new WebhookService() with no arguments uses WEBHOOKSAPIKEY from config.properties; load the file with ConfigurationManager.getProperties first. WebhookService doesn’t use APIKEY. Every method throws PauboxWebhooksException before sending a request if no key is set.

Events

The SDK doesn’t check event names. The API returns 422 for an unknown event and 403 for an event the key isn’t scoped for. Email API keys created in the Paubox Dashboard are limited to a sender domain, so subscribe to inbound mail in the Paubox Dashboard under Settings > Webhooks. For payloads and signature verification, see Webhooks.

List webhook endpoints

listWebhookEndpoints() with no arguments returns the first page. getPageInfo().getCount() is the total number of endpoints, not the length of this page. Endpoints carrying an event the key isn’t scoped for are left out.

Create a webhook endpoint

The target URL must be an https URL that doesn’t point at a private or internal address. WebhookEndpoint has getId() (a UUID), getTargetUrl(), getStatus() (active or disabled), getEvents(), getCreatedAt(), and getUpdatedAt(). CreatedWebhookEndpoint extends it with getSigningSecret(), which is returned only by this call; store it when you create the endpoint. To replace a lost secret, delete the endpoint and create a new one.

Get a webhook endpoint

Update a webhook endpoint

UpdateWebhookEndpointRequest has setTargetUrl, setStatus ("active" or "disabled"), and setEvents. Only the fields you set are sent. setEvents replaces the endpoint’s event list.

Delete a webhook endpoint

Error handling

A non-2xx response throws PauboxWebhooksException, which provides getStatusCode(), getUrl(), and getResponseBody(); its message includes the API’s error text. Creating a second endpoint for the same target URL returns 422, and an ID that isn’t on your account returns 404. An ID that isn’t a UUID throws before any request is sent, with getStatusCode() of 0. Every method is declared throws Exception, so call it from a method that declares or handles Exception. Network failures throw IOException, not PauboxWebhooksException. The data classes are in com.paubox.data.