Webhooks
Alguna provides webhooks to notify you about events that happen in your account. Webhooks are a way to receive real-time notifications when an event occurs in Alguna. Webhooks are particularly useful for asynchronous events like when a new customer is created, a quote is activated, or an invoice is paid.
Format
Alguna follows the Standard Webhooks specification for its webhooks. The payload of the webhook will be a JSON object with the following structure:
type
- The type of event that occurred. The type will be a string that represents the event that occurred. For example,invoice.paid
,quote.activated
timestamp
- The time at which the event occurred in RFC 3339 format.data
- The data associated with the event. This will be a specific shape of object, depending on the event type.
Objects
Invoice
Supported Events
Currently, Alguna supports the following events:
invoice.issued
- Sent when an invoice is issued. Returns the invoice object.invoice.paid
- Sent when an invoice is paid. Returns the invoice object.
Example
Combining the Standard Webhooks specification above, alongside the Invoice object, gives us the complete payload:
Responding to Webhooks
The way to indicate that a webhook has been processed is by returning a 2xx (status code 200-299) response to the webhook message within a reasonable time-frame (15s). It’s also important to disable CSRF protection for this endpoint if the framework you use enables them by default.
Verifying Webhooks
Webhook signatures is your way to verify that webhook messages are sent by us. For a more detailed explanation, check out this article on why you should verify webhooks.
Authenticating webhook signatures
To verify your webhooks, you will need to use the secret key that is provided in your account settings, along with headers and the payload that was sent to you.
Our webhook partner Svix offers a set of useful libraries that make verifying webhooks very simple. Here is a an example using Javascript:
IP Whitelist
In case your webhook receiving endpoint is behind a firewall or NAT, you may need to allow traffic from Svix’s IP addresses.
Retries
We attempt to deliver each webhook message based on a retry schedule with exponential backoff. Each message is attempted based on the following schedule, where each period is started following the failure of the preceding attempt:
- Immediately
- 5 seconds
- 5 minutes
- 30 minutes
- 2 hours
- 5 hours
- 10 hours
- 10 hours (in addition to the previous)
Disabling failing endpoints
If all attempts to a specific endpoint fail for a period of 5 days, the endpoint will be disabled.