Overview
Introduction
Webhooks submit real-time user data to your own HTTP endpoints. A Webhook is an HTTP callback: a simple event-notification using HTTP POST. A web application implementing Webhooks will POST a message to a URL when certain things happen.
Getting started
- Go to Hub and click on Settings page
- On the right side of the page, your current Webhooks are displayed
- Click the "+" button
- Add the URL you would like to receive Webhooks to
- If you require authentication, add in a shared secret
Actions
PrintedDirect dispatches webhooks for different actions, such as when Jobs progress through the system, or when a JobBatch is dispatched.
PrintedDirect does not currently allow subscribing to specific actions at this time. This means you will receive a webhook for every action that has a webhook defined for it.
To view the actions that PrintedDirect sends, with example payloads, see the Actions page.
Webhook timeouts
When receiving a webhook, your service must respond within 10 seconds or PrintedDirect will log this is a timeout error.
PrintedDirect does not currently retry failed webhooks at this time.
Appendices
Authentication
If you want to authenticate the requests being sent to your webhook endpoint, you can specify a shared secret when creating your webhook. Once provided, PrintedDirect signs your requests using the shared secret and the body of the request, and add that as the X-Signature
header.
PrintedDirect calculates a SHA256 digest using the shared secret and the JSON-stringified body of the request.
An example of how one might authenticate the requests would be:
const signature = req.headers['x-signature'];
const digest = crypto
.createHmac('sha1', settings.sharedSecret)
.update(new Buffer(JSON.stringify(req.body), 'utf-8'))
.digest('hex');
if (signature === digest) {
// payload verified.
}
SSL certificates
PrintedDirect webhooks are incompatible with self-signed certificates. If we detect a self-signed certificate, it will generate an error, preventing any requests from being sent.
Retries
PrintedDirect does not currently support retrying failed webhooks. This is on our roadmap for future improvements.