Skip to main content

About Webhooks

The Webhooks enables you to easily integrate and connect the Print.App platform to your outside platforms. For instance, you may want to send the PDF file of a project directly to your printer, or save all your user’s uploaded pictures in your DropBox or Google Drive. A Webhook makes this possible by invoking your specified external URL whenever an even happens on the Print.App platform along with the details of such an event for further actions. At the moment, we can notify you when:
  • A new project is created, the first time a customer’s design is saved. That can be an autosave, before the customer has finished.
  • A file is uploaded by your customer.
The exact payloads are at the end of this page. To check that a webhook really comes from Print.App, turn on signing. You can utilize the new-project Webhook to send the completed PDF/JPEG/PNG files to your print service provider.

Setting up a Webhook

To get started, navigate to the settings page in your Print.App admin and click the Webhooks tab. We need a service URL to send that notification to, for that service to get the file and save in a Google Drive. For this, we can use Zapier, a service that connects different apps and services together. We will create a Zap that listens to the Webhook notification and saves the file in your Google Drive.
1

Start

Register or login to Zapier and click the Make a Zap button on the top left hand corner. A Zap is simply a workflow link you create between apps on Zapier. You can read more here
2

Add a Trigger

That should take you to the Zap creation dashboard. Click the Trigger buttonZap Trigger
3

Select a Trigger

A window should popup, type in Webhook And select the Webhooks by Zapier optionZap Trigger select
4

Trigger Hook

On the right panel, click the Event and select Catch Hook optionZap Trigger hook
5

Obtain Trigger URL

Click next twice to arrive on the Test tab. This should give you a URL to send the file to. Copy this URLZap Trigger test
6

Add URL to Print.App settings

Open a new Tab and navigate to Print.App Settings Click the Webhooks Tab and paste the URL copied from the prior step and saveZap setting
7

Test Trigger

On the Zapier page, click on the Test trigger button. Then quickly create a new customization / project on your store and save. Check the Zapier page, you should see a record from Print.AppZap Record
8

Action

Click the Continue with record to choose an Action.
An Action is what happens after the Trigger event and for this, we will select Google Drive. You can opt for any other service you want to save the file to or even send as an email.
Zap Google Drive
9

Google Drive Event

Select Upload File from the event listZap Drive Event
10

Select File to Upload

Give Zapier permission to access your Google Drive account and click Next. Under action, scroll to the File section to pick which file you want to upload from the Print.App notification. Select the PDF file from the Print.App notification.Zap Drive Event
11

File Saved

Click the Test Step and Zapier should send the newly created PDF file to your Google Drive. You can check your Google Drive to confirm.Zap Drive
12

Save and Publish

Publish your Zap to save it.

Payloads

Each webhook is an HTTP POST with a JSON body. It carries these headers: New project
author is the userId your page passed to the editor, if any. product is the product object your page passed, or null. The pdf, png, jpeg and tiff links render the file from the project’s current state when you request them. File uploaded
url is a download link that expires after one hour.

Delivery

  • You can enter several URLs for an event, separated by commas. Each one receives every event.
  • Each event is sent once. Failed deliveries are not retried, so make your endpoint answer quickly with a 2xx. In rare cases an event can arrive twice, so ignore a PrintApp-Event-Id you have already handled.
  • With signing on, your server can reject anything that isn’t from Print.App. Without it, confirm a project with the REST API before you act on it: a 200 there confirms the project is yours.

Verify a signature

Signing is off until you turn it on. Once it’s on, every webhook carries a PrintApp-Signature header that proves it came from Print.App and was sent recently. Turn it on: in the Print.App admin, open Domains, expand your current domain, click Manage next to Secret keys, then Create signing secret under Webhook signing. Copy the secret (whsec_…) to your server. You can reveal it again there later. The header looks like this:
t is when the webhook was sent, in Unix seconds. v1 is the hex HMAC-SHA256 of t, a full stop and the raw request body, keyed with your secret. To verify:
  1. Read the raw request body, before any JSON parsing. Re-serialized JSON won’t match.
  2. Compute the HMAC of <t>.<raw body> and compare it with each v1, in constant time.
  3. Reject the request if no v1 matches, or if t is more than 5 minutes from your clock. The time check stops an old request being replayed.
Rolling the secret: click Roll secret. The new secret starts signing at once, and the previous one keeps signing alongside it for 24 hours, so the header carries two v1 values. Update your server within that day; the code above accepts either. Stop signing deletes the secret and sends webhooks unsigned again.