Webhook endpoint methods require SDK 2.0.0 or later. They are on
paubox::webhooks::WebhooksClient, not on the PauboxClient you use to send email.WebhooksClient 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. It requires the webhooks feature (enabled by default).
Create the client
WebhooksClient::with_base_url(api_key, url) overrides the base URL with a url::Url, and WebhooksClient::with_http(api_key, http) uses your own reqwest::Client. The client doesn’t read an environment variable.
All methods are async and return Result<T, PauboxError>.
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
&ListWebhookEndpointsParams::default() for the first page. page_info.count is the total number of endpoints, not the length of data. Endpoints carrying an event the key isn’t scoped for are left out.
Create a webhook endpoint
https URL that doesn’t point at a private or internal address. create_webhook_endpoint returns a CreatedWebhookEndpoint, with the endpoint in endpoint and the secret in signing_secret. WebhookEndpoint has id (a UUID), target_url, status (active or disabled), events, created_at, and updated_at. The signing secret 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
UpdateWebhookEndpoint has optional target_url, status ("active" or "disabled"), and events fields. Only the fields you set are sent. events replaces the endpoint’s event list.
Delete a webhook endpoint
Error handling
PauboxError::Auth; any other non-2xx response returns PauboxError::Http. Both carry 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 returns PauboxError::Validation before any request is sent.