Webhook endpoint methods require SDK 2.0.0 or later. They are on
*paubox.WebhooksClient, not on the *paubox.Client you use to send email.*paubox.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.
Create the client
NewWebhooks returns an error if the key is empty. It accepts WithWebhooksBaseURL, WithWebhooksHTTPClient, WithWebhooksTimeout, WithWebhooksRetry, and WithWebhooksUserAgent options. The client is safe for concurrent use.
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
nil for the default page. PageInfo.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
TargetURL must be an https URL that doesn’t point at a private or internal address. CreateWebhookEndpoint returns a *paubox.CreatedWebhookEndpoint, which embeds paubox.WebhookEndpoint (ID, TargetURL, Status, Events, CreatedAt, UpdatedAt) and adds SigningSecret. 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
UpdateWebhookEndpointRequest has optional TargetURL, 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
*paubox.PauboxError, the same type the email and forms clients return, with the API’s error text in Title. Creating a second endpoint for the same TargetURL returns 422, and an ID that isn’t on your account returns 404. An ID that isn’t a UUID returns an error before any request is sent.